1 14 package org.compiere.plaf; 15 16 import java.awt.Graphics ; 17 import java.awt.Graphics2D ; 18 19 import javax.swing.AbstractButton ; 20 import javax.swing.ButtonModel ; 21 import javax.swing.JComponent ; 22 import javax.swing.plaf.ComponentUI ; 23 import javax.swing.plaf.metal.MetalToggleButtonUI ; 24 25 31 public class CompiereToggleButtonUI extends MetalToggleButtonUI 32 { 33 38 public static ComponentUI createUI (JComponent c) 39 { 40 return s_toggleButtonUI; 41 } 43 44 private static CompiereToggleButtonUI s_toggleButtonUI = new CompiereToggleButtonUI(); 45 46 47 48 52 public void installDefaults(AbstractButton b) 53 { 54 super.installDefaults(b); 55 b.setOpaque(false); 56 } 58 73 public void update(Graphics g, JComponent c) 74 { 75 if (c.isOpaque()) CompiereUtils.fillRectange((Graphics2D )g, c, CompiereLookAndFeel.ROUND); 77 paint (g, c); 78 } 80 85 public void paint(Graphics g, JComponent c) 86 { 87 super.paint(g, c); 88 AbstractButton b = (AbstractButton ) c; 89 ButtonModel model = b.getModel(); 90 boolean in = model.isPressed() || model.isSelected(); 91 CompiereUtils.paint3Deffect((Graphics2D )g, c, CompiereLookAndFeel.ROUND, !in); 93 } 95 100 protected void paintButtonPressed(Graphics g, AbstractButton b) 101 { 102 } 110 } | Popular Tags |