1 19 20 package org.netbeans.swing.tabcontrol.plaf; 21 22 import java.awt.Color ; 23 import java.awt.Dimension ; 24 import java.awt.Font ; 25 import java.awt.FontMetrics ; 26 import java.awt.Graphics ; 27 import java.awt.Graphics2D ; 28 import java.awt.Insets ; 29 import java.awt.Rectangle ; 30 31 import javax.swing.plaf.basic.BasicToggleButtonUI ; 32 import java.awt.geom.AffineTransform ; 33 import javax.swing.AbstractButton ; 34 import javax.swing.BorderFactory ; 35 import javax.swing.ButtonModel ; 36 import javax.swing.Icon ; 37 import javax.swing.JComponent ; 38 import javax.swing.JToggleButton ; 39 import javax.swing.JToolBar ; 40 import javax.swing.SwingUtilities ; 41 import javax.swing.UIManager ; 42 import javax.swing.plaf.ComponentUI ; 43 import javax.swing.plaf.basic.BasicHTML ; 44 import javax.swing.plaf.metal.MetalToggleButtonUI ; 45 import javax.swing.text.View ; 46 import org.netbeans.swing.tabcontrol.SlideBarDataModel; 47 import org.netbeans.swing.tabcontrol.SlidingButton; 48 import org.netbeans.swing.tabcontrol.SlidingButtonUI; 49 50 56 public class GtkSlidingButtonUI extends SlidingButtonUI { 57 private boolean defaults_initialized = false; 59 protected JToggleButton hiddenToggle; 60 61 private static final GtkSlidingButtonUI INSTANCE = new GtkSlidingButtonUI(); 62 63 private GtkSlidingButtonUI() { 64 } 65 66 public static ComponentUI createUI(JComponent c) { 67 return INSTANCE; 68 } 69 70 71 public void installDefaults (AbstractButton b) { 72 super.installDefaults(b); 73 if(!defaults_initialized) { 74 hiddenToggle = new JToggleButton (); 75 hiddenToggle.setText(""); 76 JToolBar bar = new JToolBar (); 77 bar.setRollover(true); 78 bar.add(hiddenToggle); 79 defaults_initialized = true; 80 } 81 } 82 83 protected void uninstallDefaults(AbstractButton b) { 84 super.uninstallDefaults(b); 85 defaults_initialized = false; 86 } 87 88 public void paint(Graphics g, JComponent c) { 89 ColorUtil.setupAntialiasing(g); 90 91 AbstractButton button = (AbstractButton )c; 92 hiddenToggle.setBorderPainted(true); 93 hiddenToggle.setRolloverEnabled(button.isRolloverEnabled()); 95 hiddenToggle.setFocusable(button.isFocusable()); 96 hiddenToggle.setFocusPainted(button.isFocusPainted()); 97 hiddenToggle.setMargin(button.getMargin()); 98 hiddenToggle.getModel().setRollover(button.getModel().isRollover()); 100 hiddenToggle.getModel().setPressed(button.getModel().isPressed()); 101 hiddenToggle.getModel().setArmed(button.getModel().isArmed()); 102 hiddenToggle.getModel().setSelected(button.getModel().isSelected()); 103 104 hiddenToggle.setBounds(button.getBounds()); 105 super.paint(g, c); 106 } 107 108 protected void paintBackground (Graphics2D g, AbstractButton button) { 109 hiddenToggle.paint(g); 110 } 111 112 protected void paintButtonPressed(Graphics g, AbstractButton b) { 113 hiddenToggle.paint(g); 114 } 115 116 } 117 | Popular Tags |