Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled
Hmm ... can't reproduce: your code looks okay, just added a main (hint,
hint :-) like
[code]
public static void main(String[] args) {
String[] elements = new String[] {
"one", "two", "three", "four",
"one", "two", "three", "four",
"one", "two", "three", "four",
};
new JXListFilterAIOOB("dummy", elements).setVisible(true);
}
[/code]
and works without throwing anything. But: don't have a 0.9.2 handy and
there's one list data event notification issue (#377-swingx, since
JXList version 1.68, midth of Mar) fixed/started since then which might
have caused the error. Could you please check against a more recent
version? Which might be difficult to get ... with Hudson sleeping and
swinglabs.org down, cvs checkout might be the only way. Sigh.
CU
Jeanette
> Hi,
>
> I have SwingX 0.9.2 and I have a strange problem:
>
> I have a JXList sorted (Ascending) with Filtered enabled and when I click a button doing:
>
> int index = shownList.getSelectedIndex();
> index = shownList.convertIndexToModel(index);
> shownListModel.remove(index);
> repaint();
>
> I have this error on shownListModel.remove(index); line (index value was 7)
>
> Exception in thread "AWT-EventQueue-1" java.lang.ArrayIndexOutOfBoundsException: 13 >= 13
> at java.util.Vector.elementAt(Vector.java:427)
> at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:70)
> at org.jdesktop.swingx.JXList$ListAdapter.getValueAt(JXList.java:1195)
> at org.jdesktop.swingx.decorator.Filter.getValueAt(Filter.java:155)
> at org.jdesktop.swingx.decorator.Filter.getValueAt(Filter.java:153)
> at org.jdesktop.swingx.decorator.FilterPipeline.getValueAt(FilterPipeline.java:461)
> at org.jdesktop.swingx.JXList$WrappingListModel.getElementAt(JXList.java:1105)
> at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1341)
> at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1292)
> at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(BasicListUI.java:2605)
> at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
> at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:137)
> at javax.swing.DefaultListSelectionModel.setValueIsAdjusting(DefaultListSelectionModel.java:668)
> at org.jdesktop.swingx.decorator.DefaultSelectionMapper.setEnabled(DefaultSelectionMapper.java:149)
> at org.jdesktop.swingx.JXList$WrappingListModel$1.intervalRemoved(JXList.java:953)
> at javax.swing.AbstractListModel.fireIntervalRemoved(AbstractListModel.java:161)
> at javax.swing.DefaultListModel.remove(DefaultListModel.java:478)
> at tools.telemetry.ui.bean.JXTableFilterChooser$3.actionPerformed(JXTableFilterChooser.java:104)
> at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
> at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
> at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
> at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
> at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
> at java.awt.Component.processMouseEvent(Component.java:6099)
> at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
> at java.awt.Component.processEvent(Component.java:5864)
> at java.awt.Container.processEvent(Container.java:2058)
> at java.awt.Component.dispatchEventImpl(Component.java:4466)
> at java.awt.Container.dispatchEventImpl(Container.java:2116)
> at java.awt.Component.dispatchEvent(Component.java:4296)
> at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
> at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
> at java.awt.Container.dispatchEventImpl(Container.java:2102)
> at java.awt.Window.dispatchEventImpl(Window.java:2454)
> at java.awt.Component.dispatchEvent(Component.java:4296)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
> at tools.telemetry.util.GlobalHotkeyManager.dispatchEvent(GlobalHotkeyManager.java:75)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:284)
> at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
>
>
> Here is my entire code:
>
> package tools.telemetry.ui.bean;
>
> import java.awt.Dimension;
> import java.awt.GridBagConstraints;
> import java.awt.GridBagLayout;
> import java.awt.Insets;
> import java.awt.event.ActionEvent;
> import java.awt.event.ActionListener;
>
> import javax.swing.BorderFactory;
> import javax.swing.DefaultListModel;
> import javax.swing.JButton;
> import javax.swing.JDialog;
> import javax.swing.JLabel;
> import javax.swing.JPanel;
> import javax.swing.JScrollPane;
>
> import org.jdesktop.swingx.JXList;
> import org.jdesktop.swingx.decorator.SortOrder;
>
> /**
> *
> * <p>Title: JXTableFilterChooser.java</p>
> * <p>Description: Allow the user to choose which value is filtered (shown)</p>
> * <p>Copyright: Copyright (c) 2008</p>
> * [@masked-domain] $Revision$
> */
> public class JXTableFilterChooser extends JDialog{
>
> private final Dimension MIN_SIZE = new Dimension(500,400);
> private JScrollPane hideListScroll;
> private JScrollPane shownListScroll;
> private JXList hideList;
> private JXList shownList;
> private DefaultListModel hideListModel;
> private DefaultListModel shownListModel;
>
> private JButton closeBtn;
> private JButton addItem;
> private JButton removeItem;
> private GridBagConstraints gc;
>
>
> public JXTableFilterChooser(String title, String[] items){
> setTitle(title);
> setLayout(new GridBagLayout());
> setResizable(true);
> setAlwaysOnTop(true);
> setMinimumSize(MIN_SIZE);
> setPreferredSize(MIN_SIZE);
>
> gc = new GridBagConstraints();
>
> hideListModel = new DefaultListModel();
> shownListModel = new DefaultListModel();
>
> for (String string : items) {
> shownListModel.addElement(string);
> }
>
> hideList = new JXList(hideListModel);
> hideList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
> hideList.setFilterEnabled(true);
> hideList.setSortOrder(SortOrder.ASCENDING);
> hideListScroll = new JScrollPane(hideList);
>
> shownList = new JXList(shownListModel);
> shownList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
> shownList.setFilterEnabled(true);
> shownList.setSortOrder(SortOrder.ASCENDING);
> shownListScroll = new JScrollPane(shownList);
>
> // CLOSE BUTTON
> closeBtn = new JButton("Close");
> closeBtn.addActionListener(new ActionListener(){
> [@masked-domain]
> public void actionPerformed(ActionEvent e) {
> setVisible(false);
> }
> });
>
> addItem = new JButton(">");
> addItem.addActionListener(new ActionListener(){
> [@masked-domain]
> public void actionPerformed(ActionEvent e) {
>
> }
> });
>
> removeItem = new JButton("<");
> removeItem.addActionListener(new ActionListener(){
> [@masked-domain]
> public void actionPerformed(ActionEvent e) {
> int index = shownList.getSelectedIndex();
>
> index = shownList.convertIndexToModel(index);
> shownListModel.remove(index);
>
> repaint();
> }
> });
>
> /*
> * Ajout des JLabel
> */
> gc.gridx = 0;
> gc.gridy = 0;
> gc.insets = new Insets(5,5,5,5);
> add(new JLabel("Hidden items"), gc);
>
> gc.gridx = 2;
> gc.insets = new Insets(5,0,5,5);
> add(new JLabel("Shown items"), gc);
>
> /*
> * Ajout des JXList
> */
> gc.gridx = 0;
> gc.gridy = 1;
> gc.gridheight = 4;
> gc.fill = GridBagConstraints.BOTH;
> gc.weightx = 0.5;
> gc.weighty = 1;
> gc.insets = new Insets(0,5,5,5);
> add(hideListScroll, gc);
>
> gc.gridx = 2;
> gc.gridy = 1;
> gc.insets = new Insets(0,0,5,5);
> add(shownListScroll, gc);
>
> /*
> * Tweak pour afficher les boutons au milieu
> */
> gc.gridx = 1;
> gc.gridy = 1;
> gc.gridheight = 1;
> gc.weightx = 0;
> add(new JPanel(), gc);
>
> gc.gridy = 4;
> add(new JPanel(), gc);
>
> /*
> * Ajout des boutons Add/Remove
> */
> gc.gridy = 2;
> gc.weighty = 0;
> add(addItem, gc);
>
> gc.gridy = 3;
> add(removeItem, gc);
>
> /*
> * Ajout du bouton Close
> */
> gc.gridy = 5;
> gc.gridx = 2;
> gc.insets = new Insets(0,0,5,5);
> gc.anchor = GridBagConstraints.EAST;
> gc.fill = GridBagConstraints.NONE;
> add(closeBtn, gc);
>
> pack();
> }
> }
>
>
> Thanks for help
> [Message sent by forum member 'grattier' (grattier)]
>
> http://forums.java.net/jive/thread.jspa?messageID=272874
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [jdnc-unsubscribe@masked-domain]
> For additional commands, e-mail: [jdnc-help@masked-domain]
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [jdnc-unsubscribe@masked-domain]
For additional commands, e-mail: [jdnc-help@masked-domain]
Other messages in this topic
| Sender | Date sent | Subject |
| [jdnc-interest@masked-domain] | Tue, 27 May 2008 10:55:31 PDT | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| Kleopatra [fastegal@masked-domain] | Thu, 15 May 2008 18:22:05 +0200 | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| [jdnc-interest@masked-domain] | Thu, 15 May 2008 09:03:53 PDT | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| Kleopatra [fastegal@masked-domain] | Fri, 09 May 2008 12:39:45 +0200 | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| Kleopatra [fastegal@masked-domain] | Fri, 09 May 2008 09:58:46 +0200 | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| Kleopatra [fastegal@masked-domain] | Fri, 09 May 2008 09:47:49 +0200 | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| [jdnc-interest@masked-domain] | Thu, 08 May 2008 11:29:03 PDT | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| [jdnc-interest@masked-domain] | Thu, 08 May 2008 10:56:14 PDT | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| Kleopatra [fastegal@masked-domain] | Tue, 06 May 2008 17:23:46 +0200 | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| [jdnc-interest@masked-domain] | Tue, 06 May 2008 07:09:36 PDT | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| [jdnc-interest@masked-domain] | Tue, 06 May 2008 05:52:09 PDT | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| [jdnc-interest@masked-domain] | Mon, 05 May 2008 20:10:24 PDT | Re: ArrayIndexOutOfBoundsException in JXList when FilterEnabled |
| [jdnc-interest@masked-domain] | Mon, 05 May 2008 20:08:52 PDT | ArrayIndexOutOfBoundsException in JXList when FilterEnabled |