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; |
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) |
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 |
/** |
/** |
740 |
*/ |
*/ |
741 |
protected InvocationMouseHandler() |
protected InvocationMouseHandler() |
742 |
{ |
{ |
743 |
|
// Nothing to do here. |
744 |
} |
} |
745 |
|
|
746 |
/** |
/** |
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 |
/** |
/** |
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 |
} |
} |
801 |
*/ |
*/ |
802 |
protected InvocationMouseMotionHandler() |
protected InvocationMouseMotionHandler() |
803 |
{ |
{ |
804 |
|
// Nothing to do here. |
805 |
} |
} |
806 |
|
|
807 |
/** |
/** |
878 |
*/ |
*/ |
879 |
protected ItemHandler() |
protected ItemHandler() |
880 |
{ |
{ |
881 |
|
// Nothing to do here. |
882 |
} |
} |
883 |
|
|
884 |
/** |
/** |
888 |
*/ |
*/ |
889 |
public void itemStateChanged(ItemEvent e) |
public void itemStateChanged(ItemEvent e) |
890 |
{ |
{ |
891 |
|
// TODO: What should be done here? |
892 |
} |
} |
893 |
} |
} |
894 |
|
|
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 |
} |
} |
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 |
|
|
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) |
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 |
|
|
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 |
|
|
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 |
} |
} |