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

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

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

revision 1.1 by mark, Sun Sep 5 11:31:06 2004 UTC revision 1.2 by mkoch, Wed Sep 22 12:43:13 2004 UTC
# Line 171  public class BasicComboPopup extends JPo Line 171  public class BasicComboPopup extends JPo
171    {    {
172      this.comboBox = comboBox;      this.comboBox = comboBox;
173      installComboBoxListeners();      installComboBoxListeners();
174        configurePopup();
     // initialize list that will be used to display elements of the combo box    
     this.list = createList();  
     ((JLabel) list.getCellRenderer()).setHorizontalAlignment(SwingConstants.LEFT);  
     configureList();  
   
     // initialize scroller. Add list to the scroller.    
     scroller = createScroller();  
     configureScroller();  
   
     // add scroller with list inside of it to JPopupMenu  
     super.add(scroller);  
   
175      setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());      setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
176    }    }
177    
# Line 199  public class BasicComboPopup extends JPo Line 187  public class BasicComboPopup extends JPo
187      int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount())      int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount())
188                        + 4;                        + 4;
189    
190        // FIXME: Uncomment this out once preferred size of JList will be working
191        // list.setPreferredSize(new Dimension(cbBounds.width, popupHeight));
192      super.setPopupSize(cbBounds.width, popupHeight);      super.setPopupSize(cbBounds.width, popupHeight);
193    
194      // location specified is relative to comboBox      // location specified is relative to comboBox
# Line 293  public class BasicComboPopup extends JPo Line 283  public class BasicComboPopup extends JPo
283     */     */
284    protected void firePopupMenuWillBecomeVisible()    protected void firePopupMenuWillBecomeVisible()
285    {    {
286      // FIXME: Need to implement      PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
287    
288        for (int i = 0; i < ll.length; i++)
289          ll[i].popupMenuWillBecomeVisible(new PopupMenuEvent(comboBox));
290    }    }
291    
292    /**    /**
# Line 302  public class BasicComboPopup extends JPo Line 295  public class BasicComboPopup extends JPo
295     */     */
296    protected void firePopupMenuWillBecomeInvisible()    protected void firePopupMenuWillBecomeInvisible()
297    {    {
298      // FIXME: Need to implement      PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
299    
300        for (int i = 0; i < ll.length; i++)
301          ll[i].popupMenuWillBecomeInvisible(new PopupMenuEvent(comboBox));
302    }    }
303    
304    /**    /**
# Line 311  public class BasicComboPopup extends JPo Line 307  public class BasicComboPopup extends JPo
307     */     */
308    protected void firePopupMenuCanceled()    protected void firePopupMenuCanceled()
309    {    {
310      // FIXME: Need to implement      PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
311    
312        for (int i = 0; i < ll.length; i++)
313          ll[i].popupMenuCanceled(new PopupMenuEvent(comboBox));
314    }    }
315    
316    /**    /**
# Line 440  public class BasicComboPopup extends JPo Line 439  public class BasicComboPopup extends JPo
439    protected void configureList()    protected void configureList()
440    {    {
441      list.setModel(comboBox.getModel());      list.setModel(comboBox.getModel());
442        list.setVisibleRowCount(comboBox.getMaximumRowCount());
     if (comboBox.getItemCount() < comboBox.getMaximumRowCount())  
       list.setVisibleRowCount(comboBox.getItemCount());  
     else  
       list.setVisibleRowCount(comboBox.getMaximumRowCount());  
443      installListListeners();      installListListeners();
444    }    }
445    
# Line 493  public class BasicComboPopup extends JPo Line 488  public class BasicComboPopup extends JPo
488     */     */
489    protected void configurePopup()    protected void configurePopup()
490    {    {
491      // FIXME: Need to implement      // initialize list that will be used to display combo box's items
492        this.list = createList();
493        ((JLabel) list.getCellRenderer()).setHorizontalAlignment(SwingConstants.LEFT);
494        configureList();
495    
496        // initialize scroller. Add list to the scroller.  
497        scroller = createScroller();
498        configureScroller();
499    
500        // add scroller with list inside of it to JPopupMenu
501        super.add(scroller);
502    }    }
503    
504    /*    /*
# Line 643  public class BasicComboPopup extends JPo Line 648  public class BasicComboPopup extends JPo
648      for (int i = 0; i < maxRowCount; i++)      for (int i = 0; i < maxRowCount; i++)
649        {        {
650          Component comp = rend.getListCellRendererComponent(list,          Component comp = rend.getListCellRendererComponent(list,
651                                                             list.getModel()                                                             comboBox.getModel()
652                                                                 .getElementAt(i),                                                                     .getElementAt(i),
653                                                             -1, false, false);                                                             -1, false, false);
654          Dimension dim = comp.getPreferredSize();          Dimension dim = comp.getPreferredSize();
655          totalHeight += dim.height;          totalHeight += dim.height;
# Line 803  public class BasicComboPopup extends JPo Line 808  public class BasicComboPopup extends JPo
808    
809      public void mouseMoved(MouseEvent anEvent)      public void mouseMoved(MouseEvent anEvent)
810      {      {
811        // FIXME: Need to implement        // Highlight list cells over which the mouse is located.
812        // NOTE: the change isn't reflected in data model of the combo box.        // This changes list model, but has no effect on combo box's data model
813        // The items are only highlited, but not selected        int index = list.locationToIndex(anEvent.getPoint());
814          list.setSelectedIndex(index);
815          list.repaint();
816      }      }
817    }    }
818    
# Line 828  public class BasicComboPopup extends JPo Line 835  public class BasicComboPopup extends JPo
835            revalidate();            revalidate();
836            repaint();            repaint();
837          }          }
838          if (e.getPropertyName().equals(JComboBox.MODEL_CHANGED_PROPERTY))
839            {
840              list.setModel((ComboBoxModel) e.getNewValue());        
841              revalidate();
842              repaint();
843            }
844      }      }
845    }    }
846    

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

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