1 package com.opensymphony.workflow.designer.swing.plaf; 2 3 import java.awt.*; 4 import javax.swing.*; 5 import javax.swing.plaf.basic.BasicButtonUI ; 6 7 public class BlueButtonUI extends BasicButtonUI 8 { 9 private Color blueishBackground = new Color(220, 225, 234); 10 private Color blueishBorder = new Color(10, 36, 106); 11 12 public BlueButtonUI() 13 { 14 super(); 15 } 16 17 public void installUI(JComponent c) 18 { 19 super.installUI(c); 20 21 AbstractButton button = (AbstractButton)c; 22 button.setRolloverEnabled(true); 23 button.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); 24 if(c.getClientProperty("showtext") != Boolean.TRUE) 25 button.setText(null); 26 } 27 28 public void paint(Graphics g, JComponent c) 29 { 30 AbstractButton button = (AbstractButton)c; 31 if(button.getModel().isRollover() || button.getModel().isArmed() || button.getModel().isSelected()) 32 { 33 Color oldColor = g.getColor(); 34 g.setColor(blueishBackground); 35 g.fillRect(0, 0, c.getWidth() - 1, c.getHeight() - 1); 36 37 g.setColor(blueishBorder); 38 g.drawRect(0, 0, c.getWidth() - 1, c.getHeight() - 1); 39 40 g.setColor(oldColor); 41 } 42 super.paint(g, c); 43 } 44 45 protected void paintButtonPressed(Graphics g, AbstractButton b) 46 { 47 setTextShiftOffset(); 48 } 49 50 protected int getTextShiftOffset() 51 { 52 return 1; 53 } 54 } 55 | Popular Tags |