46 |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyEvent; |
47 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeEvent; |
48 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
|
import java.io.IOException; |
|
|
import java.io.ObjectOutputStream; |
|
49 |
import java.util.Vector; |
import java.util.Vector; |
50 |
|
|
51 |
import javax.accessibility.Accessible; |
import javax.accessibility.Accessible; |
56 |
import javax.swing.event.ListDataEvent; |
import javax.swing.event.ListDataEvent; |
57 |
import javax.swing.event.ListDataListener; |
import javax.swing.event.ListDataListener; |
58 |
import javax.swing.event.PopupMenuListener; |
import javax.swing.event.PopupMenuListener; |
59 |
|
import javax.swing.event.PopupMenuEvent; |
60 |
import javax.swing.plaf.ComboBoxUI; |
import javax.swing.plaf.ComboBoxUI; |
61 |
|
|
62 |
/** |
/** |
211 |
this(new DefaultComboBoxModel()); |
this(new DefaultComboBoxModel()); |
212 |
} |
} |
213 |
|
|
|
private void writeObject(ObjectOutputStream stream) throws IOException |
|
|
{ |
|
|
} |
|
|
|
|
214 |
/** |
/** |
215 |
* This method returns true JComboBox is editable and false otherwise |
* This method returns true JComboBox is editable and false otherwise |
216 |
* |
* |
305 |
// Stores old data model for event notification. |
// Stores old data model for event notification. |
306 |
ComboBoxModel oldDataModel = dataModel; |
ComboBoxModel oldDataModel = dataModel; |
307 |
dataModel = newDataModel; |
dataModel = newDataModel; |
308 |
|
selectedItemReminder = newDataModel.getSelectedItem(); |
309 |
|
|
310 |
// Notifies the listeners of the model change. |
// Notifies the listeners of the model change. |
311 |
firePropertyChange("model", oldDataModel, dataModel); |
firePropertyChange("model", oldDataModel, dataModel); |
312 |
} |
} |
839 |
} |
} |
840 |
|
|
841 |
/** |
/** |
842 |
|
* Fires a popupMenuCanceled() event to all <code>PopupMenuListeners</code>. |
843 |
|
* |
844 |
|
* Note: This method is intended for use by plaf classes only. |
845 |
|
*/ |
846 |
|
public void firePopupMenuCanceled() |
847 |
|
{ |
848 |
|
PopupMenuListener[] listeners = getPopupMenuListeners(); |
849 |
|
PopupMenuEvent e = new PopupMenuEvent(this); |
850 |
|
for(int i = 0; i < listeners.length; i++) |
851 |
|
listeners[i].popupMenuCanceled(e); |
852 |
|
} |
853 |
|
|
854 |
|
/** |
855 |
|
* Fires a popupMenuWillBecomeInvisible() event to all |
856 |
|
* <code>PopupMenuListeners</code>. |
857 |
|
* |
858 |
|
* Note: This method is intended for use by plaf classes only. |
859 |
|
*/ |
860 |
|
public void firePopupMenuWillBecomeInvisible() |
861 |
|
{ |
862 |
|
PopupMenuListener[] listeners = getPopupMenuListeners(); |
863 |
|
PopupMenuEvent e = new PopupMenuEvent(this); |
864 |
|
for(int i = 0; i < listeners.length; i++) |
865 |
|
listeners[i].popupMenuWillBecomeInvisible(e); |
866 |
|
} |
867 |
|
|
868 |
|
/** |
869 |
|
* Fires a popupMenuWillBecomeVisible() event to all |
870 |
|
* <code>PopupMenuListeners</code>. |
871 |
|
* |
872 |
|
* Note: This method is intended for use by plaf classes only. |
873 |
|
*/ |
874 |
|
public void firePopupMenuWillBecomeVisible() |
875 |
|
{ |
876 |
|
PopupMenuListener[] listeners = getPopupMenuListeners(); |
877 |
|
PopupMenuEvent e = new PopupMenuEvent(this); |
878 |
|
for(int i = 0; i < listeners.length; i++) |
879 |
|
listeners[i].popupMenuWillBecomeVisible(e); |
880 |
|
} |
881 |
|
|
882 |
|
/** |
883 |
* This method is invoked whenever selected item changes in the combo box's |
* This method is invoked whenever selected item changes in the combo box's |
884 |
* data model. It fires ItemEvent and ActionEvent to all registered |
* data model. It fires ItemEvent and ActionEvent to all registered |
885 |
* ComboBox's ItemListeners and ActionListeners respectively, indicating |
* ComboBox's ItemListeners and ActionListeners respectively, indicating |
896 |
|
|
897 |
// Fire ItemEvent to indicate that new item is selected |
// Fire ItemEvent to indicate that new item is selected |
898 |
Object newSelection = getSelectedItem(); |
Object newSelection = getSelectedItem(); |
899 |
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, |
if (newSelection != null) |
900 |
newSelection, ItemEvent.SELECTED)); |
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, |
901 |
|
newSelection, ItemEvent.SELECTED)); |
902 |
|
|
903 |
// Fire Action Event to JComboBox's registered listeners |
// Fire Action Event to JComboBox's registered listeners |
904 |
fireActionEvent(); |
fireActionEvent(); |
1022 |
*/ |
*/ |
1023 |
public void processKeyEvent(KeyEvent e) |
public void processKeyEvent(KeyEvent e) |
1024 |
{ |
{ |
1025 |
} |
if (e.getKeyCode() == KeyEvent.VK_TAB) |
1026 |
|
setPopupVisible(false); |
1027 |
/** |
else if (keySelectionManager != null) |
1028 |
* This method always returns false to indicate that JComboBox itself is |
{ |
1029 |
* not focus traversable. |
int i = keySelectionManager.selectionForKey(e.getKeyChar(), |
1030 |
* |
getModel()); |
1031 |
* @return false to indicate that JComboBox itself is not focus traversable. |
if (i >= 0) |
1032 |
* |
setSelectedIndex(i); |
1033 |
* @deprecated |
else |
1034 |
*/ |
super.processKeyEvent(e); |
1035 |
public boolean isFocusTraversable() |
} |
1036 |
{ |
else |
1037 |
return false; |
super.processKeyEvent(e); |
1038 |
} |
} |
1039 |
|
|
1040 |
/** |
/** |
1044 |
*/ |
*/ |
1045 |
public void setKeySelectionManager(KeySelectionManager aManager) |
public void setKeySelectionManager(KeySelectionManager aManager) |
1046 |
{ |
{ |
1047 |
|
keySelectionManager = aManager; |
1048 |
} |
} |
1049 |
|
|
1050 |
/** |
/** |
1209 |
|
|
1210 |
protected AccessibleJComboBox() |
protected AccessibleJComboBox() |
1211 |
{ |
{ |
1212 |
|
// Nothing to do here. |
1213 |
} |
} |
1214 |
|
|
1215 |
public int getAccessibleChildrenCount() |
public int getAccessibleChildrenCount() |
1269 |
|
|
1270 |
public void addAccessibleSelection(int value0) |
public void addAccessibleSelection(int value0) |
1271 |
{ |
{ |
1272 |
|
// TODO: Implement this properly. |
1273 |
} |
} |
1274 |
|
|
1275 |
public void removeAccessibleSelection(int value0) |
public void removeAccessibleSelection(int value0) |
1276 |
{ |
{ |
1277 |
|
// TODO: Implement this properly. |
1278 |
} |
} |
1279 |
|
|
1280 |
public void clearAccessibleSelection() |
public void clearAccessibleSelection() |
1281 |
{ |
{ |
1282 |
|
// TODO: Implement this properly. |
1283 |
} |
} |
1284 |
|
|
1285 |
public void selectAllAccessibleSelection() |
public void selectAllAccessibleSelection() |
1286 |
{ |
{ |
1287 |
|
// TODO: Implement this properly. |
1288 |
} |
} |
1289 |
} |
} |
1290 |
} |
} |