Issue Details (XML | Word | Printable)

Key: SWINGX-1337
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Karl Schaefer
Reporter: andrei_pozolotin
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
swingx

NameComboBoxModel does not implement ComboBoxModel properly

Created: 01/Sep/10 08:57 AM   Updated: 28/Jan/11 12:54 PM   Resolved: 28/Oct/10 02:39 PM
Component/s: Authentication
Affects Version/s: 1.6.1
Fix Version/s: 1.6.3

Time Tracking:
Not Specified

Environment:

Operating System: Mac OS X
Platform: All


Issuezilla Id: 1,337
Tags:
Participants: andrei_pozolotin and Karl Schaefer


 Description  « Hide

NameComboBoxModel does not implement ComboBoxModel properly

namely:

public Object getElementAt(int index) { return userNameStore.getUserNames()[index]; }

fails with this exception on mac os x (aqua plaf):

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at
org.jdesktop.swingx.JXLoginPane$ComboNamePanel$NameComboBoxModel.getElementAt(JXLoginPane.java:1593)
at com.apple.laf.AquaComboBoxUI$1.itemStateChanged(AquaComboBoxUI.java:88)
at javax.swing.JComboBox.fireItemStateChanged(JComboBox.java:1205)
at javax.swing.JComboBox.selectedItemChanged(JComboBox.java:1262)
at javax.swing.JComboBox.contentsChanged(JComboBox.java:1309)
at javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:100)
at
org.jdesktop.swingx.JXLoginPane$ComboNamePanel$NameComboBoxModel.setSelectedItem(JXLoginPane.java:1587)
at javax.swing.JComboBox.setSelectedItem(JComboBox.java:557)
at
org.jdesktop.swingx.autocomplete.ComboBoxAdaptor.setSelectedItem(ComboBoxAdaptor.java:104)
at
org.jdesktop.swingx.autocomplete.AutoCompleteDocument.setSelectedItem(AutoCompleteDocument.java:305)
at
org.jdesktop.swingx.autocomplete.AutoCompleteDocument.insertString(AutoCompleteDocument.java:274)
at javax.swing.text.JTextComponent.replaceSelection(JTextComponent.java:1358)
at
javax.swing.text.DefaultEditorKit$DefaultKeyTypedAction.actionPerformed(DefaultEditorKit.java:864)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1639)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2851)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2886)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2814)
at java.awt.Component.processEvent(Component.java:6125)
at java.awt.Container.processEvent(Container.java:2085)
at java.awt.Component.dispatchEventImpl(Component.java:4714)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1850)
at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:712)
at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:990)
at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:855)
at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:676)
at java.awt.Component.dispatchEventImpl(Component.java:4586)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

this is because "-1" is a valid value for index per spec:

http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/SingleSelectionModel.html#getSelectedIndex%28%29

"Returns:
the model's selection, or -1 if there is no selection"

something like this resolves the issue:

public Object getElementAt(int index) {
if(index <0 || index > getSize()){ return null; }
return userNameStore.getUserNames()[index];
}

this "-1" happens only on mac, windows and linux run original code fine;

thank you!



Sort Order: Ascending order - Click to sort in descending order
kenaiadmin made changes - 25/Jan/11 02:05 PM
Field Original Value New Value
issue.field.bugzillaimportkey 1337 85597
Karl Schaefer made changes - 28/Jan/11 12:54 PM
Affects Version/s 1.6.1 [ 13360 ]
Affects Version/s 1.6++ [ 13359 ]