/[classpath]/classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by trebligd, Wed Aug 31 15:23:10 2005 UTC revision 1.12 by rabbit78, Wed Sep 28 15:17:42 2005 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package javax.swing.plaf.basic;  package javax.swing.plaf.basic;
40    
41    import java.awt.Font;
42    import java.awt.Graphics;
43    import java.awt.Rectangle;
44    
45    import javax.swing.AbstractButton;
46  import javax.swing.JComponent;  import javax.swing.JComponent;
47    import javax.swing.SwingUtilities;
48  import javax.swing.plaf.ComponentUI;  import javax.swing.plaf.ComponentUI;
49    
50  public class BasicToggleButtonUI extends BasicButtonUI  public class BasicToggleButtonUI extends BasicButtonUI
# Line 58  public class BasicToggleButtonUI extends Line 64  public class BasicToggleButtonUI extends
64    {    {
65      return "ToggleButton.";      return "ToggleButton.";
66    }    }
 }  
67    
68      /**
69       * Paint the component, which is an {@link AbstractButton}, according to
70       * its current state.
71       *
72       * @param g The graphics context to paint with
73       * @param c The component to paint the state of
74       */
75      public void paint(Graphics g, JComponent c)
76      {      
77        AbstractButton b = (AbstractButton) c;
78    
79        Rectangle tr = new Rectangle();
80        Rectangle ir = new Rectangle();
81        Rectangle vr = new Rectangle();
82    
83        Font f = c.getFont();
84    
85        g.setFont(f);
86    
87        if (b.isBorderPainted())
88          SwingUtilities.calculateInnerArea(b, vr);
89        else
90          vr = SwingUtilities.getLocalBounds(b);
91        String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f),
92                                                         b.getText(),
93                                                         currentIcon(b),
94                                                         b.getVerticalAlignment(),
95                                                         b.getHorizontalAlignment(),
96                                                         b.getVerticalTextPosition(),
97                                                         b.getHorizontalTextPosition(),
98                                                         vr, ir, tr,
99                                                         b.getIconTextGap()
100                                                         + defaultTextShiftOffset);
101    
102        if ((b.getModel().isArmed() && b.getModel().isPressed())
103            || b.isSelected())
104          paintButtonPressed(g, b);
105    
106        paintIcon(g, b, ir);
107        if (text != null)
108          paintText(g, b, tr, text);
109        if (b.isFocusOwner())
110          paintFocus(g, b, vr, tr, ir);
111      }
112    
113      /**
114       * Paints the icon for the toggle button. This delegates to
115       * {@link BasicButtonUI#paintIcon(Graphics, JComponent, Rectangle)}.
116       *
117       * @param g the graphics context
118       * @param b the button to paint the icon for
119       * @param iconRect the area allocated for the icon
120       */
121      protected void paintIcon(Graphics g, AbstractButton b, Rectangle iconRect)
122      {
123        super.paintIcon(g, b, iconRect);
124      }
125    }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26