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

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

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

revision 1.13 by trebligd, Sun Sep 18 10:41:11 2005 UTC revision 1.14 by trebligd, Sun Sep 18 13:39:54 2005 UTC
# Line 165  public class BasicComboBoxUI extends Com Line 165  public class BasicComboBoxUI extends Com
165    /* Size of the largest item in the comboBox    /* Size of the largest item in the comboBox
166     * This is package-private to avoid an accessor method.     * This is package-private to avoid an accessor method.
167     */     */
168    Dimension largestItemSize;    Dimension displaySize;
169    
170    // It seems that JComboBox doesn't have a border set explicitely. So we just    // It seems that JComboBox doesn't have a border set explicitely. So we just
171    // paint the border everytime combo box is displayed.    // paint the border everytime combo box is displayed.
# Line 874  public class BasicComboBoxUI extends Com Line 874  public class BasicComboBoxUI extends Com
874     *     *
875     * @return dimensions of the largest item in the combo box.     * @return dimensions of the largest item in the combo box.
876     */     */
877    private Dimension getLargestItemSize()    protected Dimension getDisplaySize()
878    {    {
879      ComboBoxModel model = comboBox.getModel();      ComboBoxModel model = comboBox.getModel();
880      int numItems = model.getSize();      int numItems = model.getSize();
# Line 883  public class BasicComboBoxUI extends Com Line 883  public class BasicComboBoxUI extends Com
883      // return its default size      // return its default size
884      if (numItems == 0)      if (numItems == 0)
885        {        {
886          largestItemSize = getDefaultSize();          displaySize = getDefaultSize();
887          return largestItemSize;          return displaySize;
888        }        }
889    
890      Dimension size = new Dimension(0, 0);      Dimension size = new Dimension(0, 0);
# Line 893  public class BasicComboBoxUI extends Com Line 893  public class BasicComboBoxUI extends Com
893      // size of the largest item in the combo box.      // size of the largest item in the combo box.
894      ListCellRenderer renderer = comboBox.getRenderer();      ListCellRenderer renderer = comboBox.getRenderer();
895    
896        // FIXME: use the JComboBox.getPrototypeDisplayValue() if there is
897        // one
898      for (int i = 0; i < numItems; i++)      for (int i = 0; i < numItems; i++)
899        {        {
900          Object item = model.getElementAt(i);          Object item = model.getElementAt(i);
# Line 904  public class BasicComboBoxUI extends Com Line 906  public class BasicComboBoxUI extends Com
906            size = comp.getPreferredSize();            size = comp.getPreferredSize();
907        }        }
908    
909      largestItemSize = size;      displaySize = size;
910      return largestItemSize;      return displaySize;
911    }    }
912    
913    /**    /**
# Line 976  public class BasicComboBoxUI extends Com Line 978  public class BasicComboBoxUI extends Com
978      {      {
979        Dimension d = new Dimension(0, 0);        Dimension d = new Dimension(0, 0);
980    
981        if (largestItemSize == null)        if (displaySize == null)
982          largestItemSize = getLargestItemSize();          displaySize = getDisplaySize();
983    
984        // add size for the area that will display selected item        // add size for the area that will display selected item
985        d.width += largestItemSize.getWidth();        d.width += displaySize.getWidth();
986        d.height += largestItemSize.getHeight();        d.height += displaySize.getHeight();
987    
988        // add size of the arrow button        // add size of the arrow button
989        d.width += arrowButtonWidth;        d.width += arrowButtonWidth;
# Line 1170  public class BasicComboBoxUI extends Com Line 1172  public class BasicComboBoxUI extends Com
1172        ComboBoxModel model = comboBox.getModel();        ComboBoxModel model = comboBox.getModel();
1173        ListCellRenderer renderer = comboBox.getRenderer();        ListCellRenderer renderer = comboBox.getRenderer();
1174    
1175        if (largestItemSize == null)        if (displaySize == null)
1176          largestItemSize = getLargestItemSize();          displaySize = getDisplaySize();
1177        if (largestItemSize.width < getDefaultSize().width)        if (displaySize.width < getDefaultSize().width)
1178          largestItemSize.width = getDefaultSize().width;          displaySize.width = getDefaultSize().width;
1179        if (largestItemSize.height < getDefaultSize().height)        if (displaySize.height < getDefaultSize().height)
1180          largestItemSize.height = getDefaultSize().height;          displaySize.height = getDefaultSize().height;
1181    
1182        comboBox.repaint();        comboBox.repaint();
1183      }      }
# Line 1189  public class BasicComboBoxUI extends Com Line 1191  public class BasicComboBoxUI extends Com
1191      public void intervalRemoved(ListDataEvent e)      public void intervalRemoved(ListDataEvent e)
1192      {      {
1193        // recalculate display size of the JComboBox.        // recalculate display size of the JComboBox.
1194        largestItemSize = getLargestItemSize();        displaySize = getDisplaySize();
1195        comboBox.repaint();        comboBox.repaint();
1196      }      }
1197    }    }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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