/[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.5.2.4 by gnu_andrew, Tue Aug 2 20:12:37 2005 UTC revision 1.5.2.5 by gnu_andrew, Wed Nov 2 00:43:52 2005 UTC
# Line 40  package javax.swing.plaf.basic; Line 40  package javax.swing.plaf.basic;
40    
41  import java.awt.Component;  import java.awt.Component;
42  import java.awt.Dimension;  import java.awt.Dimension;
43    import java.awt.Insets;
44  import java.awt.Point;  import java.awt.Point;
45  import java.awt.Rectangle;  import java.awt.Rectangle;
46  import java.awt.event.ItemEvent;  import java.awt.event.ItemEvent;
# Line 179  public class BasicComboPopup extends JPo Line 180  public class BasicComboPopup extends JPo
180      int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount());      int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
181    
182      list.setPreferredSize(new Dimension(cbBounds.width, popupHeight));      list.setPreferredSize(new Dimension(cbBounds.width, popupHeight));
183      super.setPopupSize(cbBounds.width, popupHeight);      Insets insets1 = getInsets();
184        Insets insets2 = scroller.getInsets();
185        super.setPopupSize(cbBounds.width, popupHeight + insets1.top
186                + insets1.bottom + insets2.top + insets2.bottom);
187    
188      // Highlight selected item in the combo box's drop down list      // Highlight selected item in the combo box's drop down list
189      if (comboBox.getSelectedIndex() != -1)      if (comboBox.getSelectedIndex() != -1)
# Line 714  public class BasicComboPopup extends JPo Line 718  public class BasicComboPopup extends JPo
718    protected void updateListBoxSelectionForEvent(MouseEvent anEvent,    protected void updateListBoxSelectionForEvent(MouseEvent anEvent,
719                                                  boolean shouldScroll)                                                  boolean shouldScroll)
720    {    {
721      // FIXME: Need to implement      // TODO: We need to handle the shouldScroll parameter somehow.
722        int index = list.locationToIndex(anEvent.getPoint());
723        // Check for valid index.
724        if (index >= 0)
725          list.setSelectedIndex(index);
726    }    }
727    
728    /**    /**
# Line 732  public class BasicComboPopup extends JPo Line 740  public class BasicComboPopup extends JPo
740       */       */
741      protected InvocationMouseHandler()      protected InvocationMouseHandler()
742      {      {
743          // Nothing to do here.
744      }      }
745    
746      /**      /**
# Line 744  public class BasicComboPopup extends JPo Line 753  public class BasicComboPopup extends JPo
753      public void mousePressed(MouseEvent e)      public void mousePressed(MouseEvent e)
754      {      {
755        if (comboBox.isEnabled())        if (comboBox.isEnabled())
756          togglePopup();          togglePopup();
757      }      }
758    
759      /**      /**
# Line 768  public class BasicComboPopup extends JPo Line 777  public class BasicComboPopup extends JPo
777        // then change selection and close popup        // then change selection and close popup
778        if (! (releasedComponent instanceof JComboBox))        if (! (releasedComponent instanceof JComboBox))
779          {          {
780            // List model contains the item over which mouse is released,            // List model contains the item over which mouse is released,
781            // since it is updated every time the mouse is moved over a different            // since it is updated every time the mouse is moved over a different
782            // item in the list. Now that the mouse is released we need to            // item in the list. Now that the mouse is released we need to
783            // update model of the combo box as well.                  // update model of the combo box as well.      
784            comboBox.setSelectedIndex(list.getSelectedIndex());            comboBox.setSelectedIndex(list.getSelectedIndex());
785    
786            if (isAutoScrolling)            if (isAutoScrolling)
787              stopAutoScrolling();              stopAutoScrolling();
788            hide();            hide();
789          }          }
790      }      }
791    }    }
# Line 792  public class BasicComboPopup extends JPo Line 801  public class BasicComboPopup extends JPo
801       */       */
802      protected InvocationMouseMotionHandler()      protected InvocationMouseMotionHandler()
803      {      {
804          // Nothing to do here.
805      }      }
806    
807      /**      /**
# Line 868  public class BasicComboPopup extends JPo Line 878  public class BasicComboPopup extends JPo
878       */       */
879      protected ItemHandler()      protected ItemHandler()
880      {      {
881          // Nothing to do here.
882      }      }
883    
884      /**      /**
# Line 877  public class BasicComboPopup extends JPo Line 888  public class BasicComboPopup extends JPo
888       */       */
889      public void itemStateChanged(ItemEvent e)      public void itemStateChanged(ItemEvent e)
890      {      {
891          // TODO: What should be done here?
892      }      }
893    }    }
894    
# Line 890  public class BasicComboPopup extends JPo Line 902  public class BasicComboPopup extends JPo
902    {    {
903      protected ListMouseHandler()      protected ListMouseHandler()
904      {      {
905          // Nothing to do here.
906      }      }
907    
908      public void mousePressed(MouseEvent e)      public void mousePressed(MouseEvent e)
909      {      {
910          // TODO: What should be do here?
911      }      }
912    
913      public void mouseReleased(MouseEvent anEvent)      public void mouseReleased(MouseEvent anEvent)
914      {      {
915        int index = list.locationToIndex(anEvent.getPoint());        int index = list.locationToIndex(anEvent.getPoint());
916        comboBox.setSelectedIndex(index);        // Check for valid index.
917          if (index >= 0)
918            comboBox.setSelectedIndex(index);
919        hide();        hide();
920      }      }
921    }    }
# Line 913  public class BasicComboPopup extends JPo Line 929  public class BasicComboPopup extends JPo
929    {    {
930      protected ListMouseMotionHandler()      protected ListMouseMotionHandler()
931      {      {
932          // Nothing to do here.
933      }      }
934    
935      public void mouseMoved(MouseEvent anEvent)      public void mouseMoved(MouseEvent anEvent)
936      {      {
937        // Highlight list cells over which the mouse is located.        updateListBoxSelectionForEvent(anEvent, false);
       // This changes list model, but has no effect on combo box's data model  
       int index = list.locationToIndex(anEvent.getPoint());  
       list.setSelectedIndex(index);  
       list.repaint();  
938      }      }
939    }    }
940    
# Line 934  public class BasicComboPopup extends JPo Line 947  public class BasicComboPopup extends JPo
947    {    {
948      protected PropertyChangeHandler()      protected PropertyChangeHandler()
949      {      {
950          // Nothing to do here.
951      }      }
952    
953      public void propertyChange(PropertyChangeEvent e)      public void propertyChange(PropertyChangeEvent e)
# Line 1009  public class BasicComboPopup extends JPo Line 1023  public class BasicComboPopup extends JPo
1023    {    {
1024      public ListDataHandler()      public ListDataHandler()
1025      {      {
1026          // Nothing to do here.
1027      }      }
1028    
1029      public void contentsChanged(ListDataEvent e)      public void contentsChanged(ListDataEvent e)
1030      {      {
1031          // Nothing to do here.
1032      }      }
1033    
1034      public void intervalAdded(ListDataEvent e)      public void intervalAdded(ListDataEvent e)
1035      {      {
1036          // Nothing to do here.
1037      }      }
1038    
1039      public void intervalRemoved(ListDataEvent e)      public void intervalRemoved(ListDataEvent e)
1040      {      {
1041          // Nothing to do here.
1042      }      }
1043    }    }
1044    
# Line 1032  public class BasicComboPopup extends JPo Line 1050  public class BasicComboPopup extends JPo
1050    {    {
1051      protected ListSelectionHandler()      protected ListSelectionHandler()
1052      {      {
1053          // Nothing to do here.
1054      }      }
1055    
1056      public void valueChanged(ListSelectionEvent e)      public void valueChanged(ListSelectionEvent e)
1057      {      {
1058          // Nothing to do here.
1059      }      }
1060    }    }
1061    
# Line 1046  public class BasicComboPopup extends JPo Line 1066  public class BasicComboPopup extends JPo
1066    {    {
1067      public InvocationKeyHandler()      public InvocationKeyHandler()
1068      {      {
1069          // Nothing to do here.
1070      }      }
1071    
1072      public void keyReleased(KeyEvent e)      public void keyReleased(KeyEvent e)
1073      {      {
1074          // Nothing to do here.
1075      }      }
1076    }    }
1077  }  }

Legend:
Removed from v.1.5.2.4  
changed lines
  Added in v.1.5.2.5

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