/[classpath]/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/metal/MetalComboBoxButton.java

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

revision 1.2 by trebligd, Fri Sep 23 16:24:27 2005 UTC revision 1.3 by trebligd, Thu Sep 29 20:19:22 2005 UTC
# Line 48  import javax.swing.Icon; Line 48  import javax.swing.Icon;
48  import javax.swing.JButton;  import javax.swing.JButton;
49  import javax.swing.JComboBox;  import javax.swing.JComboBox;
50  import javax.swing.JList;  import javax.swing.JList;
51    import javax.swing.SwingConstants;
52  import javax.swing.SwingUtilities;  import javax.swing.SwingUtilities;
53    
54  /**  /**
# Line 99  public class MetalComboBoxButton extends Line 100  public class MetalComboBoxButton extends
100    public MetalComboBoxButton(JComboBox cb, Icon i, boolean onlyIcon,    public MetalComboBoxButton(JComboBox cb, Icon i, boolean onlyIcon,
101        CellRendererPane pane, JList list)        CellRendererPane pane, JList list)
102    {    {
103      super(i);      super();
104      comboBox = cb;      comboBox = cb;
105      comboIcon = i;      comboIcon = i;
106      iconOnly = onlyIcon;      iconOnly = onlyIcon;
# Line 200  public class MetalComboBoxButton extends Line 201  public class MetalComboBoxButton extends
201     */     */
202    public void paintComponent(Graphics g)    public void paintComponent(Graphics g)
203    {    {
204        super.paintComponent(g);
205      if (iconOnly)      if (iconOnly)
206        {        {
207          Rectangle bounds = getBounds();          Rectangle bounds = getBounds();
# Line 231  public class MetalComboBoxButton extends Line 233  public class MetalComboBoxButton extends
233          else          else
234            g.setColor(MetalLookAndFeel.getControlDisabled());            g.setColor(MetalLookAndFeel.getControlDisabled());
235          FontMetrics fm = g.getFontMetrics(comboBox.getFont());          FontMetrics fm = g.getFontMetrics(comboBox.getFont());
236          // FIXME: the label may need truncating with '...' and the          Rectangle textR = new Rectangle();
237          // alignment needs work          text = SwingUtilities.layoutCompoundLabel(fm, text, null,
238          g.drawString(text, insets.left + 5, fm.getAscent() + 4);              SwingConstants.TOP, SwingConstants.LEFT,
239                SwingConstants.CENTER, SwingConstants.RIGHT,
240                innerArea, new Rectangle(), textR, 0);
241            int yAdj = (textR.height - fm.getAscent()) / 2 + 1;
242            g.setFont(comboBox.getFont());
243            g.drawString(text, textR.x, textR.y + textR.height - yAdj);
244        }        }
245    }    }
246  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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