fbayle created GLAZEDLISTS-575:
----------------------------------
Summary: IndexOutOfBoundsException with AutoCompleteSupport
Key: GLAZEDLISTS-575
URL:
https://java.net/jira/browse/GLAZEDLISTS-575 Project: glazedlists
Issue Type: Bug
Components: core
Affects Versions: 1.9.0
Reporter: fbayle
Assignee: jessewilson
The following code throws an IndexOutOfBoundsException when you type "de<enter>" in the JComboBox:
{code:title=TestAutoComplete.java|borderStyle=solid}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new JFrame() {
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComboBox<String> jc = new JComboBox<String>();
jc.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
EventList<String> entries = new BasicEventList<>();
for (int i = 0; i < 10; i++) {
entries.add("sweden");
entries.add("jordan");
}
entries.add("denmark");
AutoCompleteSupport<String> autocompleteSupport = AutoCompleteSupport.install(jc, entries);
autocompleteSupport.setFilterMode(TextMatcherEditor.CONTAINS);
this.add(jc);
this.pack();
this.setVisible(true);
}
};
}
});
}
{code}
This seems to be due to the fact that the item selected remains the same between "d" and "e" key press, whereas the index of the selected item is changing due to the filter. It seems that the selection model isn't updated when the list is filtered.
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)