Skip to main content

ArrayIndexOutOfBoundsException in JXList when FilterEnabled

13 replies [Last post]
grattier
Offline
Joined: 2008-01-30

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)

Message was edited by: grattier

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kleopatra

jdnc-interest@javadesktop.org schrieb:
> Hi,
>
> I confirm that Weekly build: swingx-2008_05_04.jar (latest at this date) works fine. The bug seems to be fixed.
>
>
>

hmm .. not sure if that's a "real" recent build - Hudson (in fact the
server where he is living) is down since a while. It's more probably the
last weekly build before his nervous breakdown, eternally replicated
with a new date. Can't be sure, though. Jan, what do you think? Some
ghost running in the background?

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

clandestino057
Offline
Joined: 2006-08-14

I have the same problem with 0.9.2. The following code works when filters are disabled but throws an ArrayBlablabaException when enabled and one of the list items are selected.

[code]
public class ListMess {
public static void main(String[] args) {
final DefaultListModel model = new DefaultListModel();
model.addElement("What");
model.addElement("the");
model.addElement("bleep");
model.addElement("is");
model.addElement("wrong");

final JXList list = new JXList(model);

list.setFilterEnabled(true);
list.setFilters( new FilterPipeline(new ShuttleSorter()));
list.addListSelectionListener( new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
Object item = list.getSelectedValue();
model.removeElement( item );
}
});

JPanel panel = new JPanel( new BorderLayout() );
panel.add( list );
JFrame frame = new JFrame();
frame.setContentPane( panel );
frame.pack();
frame.setVisible( true );
}
}
[/code]

Is this bug related to issue #2? Didn't want to create an extra entry in the issue tracker.

Fondest regards,
Erik

Kleopatra

Erik,
> I have the same problem with 0.9.2. The following code works when filters are disabled but throws an ArrayBlablabaException when enabled and one of the list items are selected.
>

same as with the other example - works fine for me with the current
swingx. Hopefully the bug (#377-swingx, probably similar to #2-swinglabs
which is mis-placed) is really fixed and solves the problem :-)

Cheers
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

grattier
Offline
Joined: 2008-01-30

Hi,

I confirm that Weekly build: swingx-2008_05_04.jar (latest at this date) works fine. The bug seems to be fixed.

Thanks for help

a+

grattier
Offline
Joined: 2008-01-30

New Bug!

After some testing, I'm not sure if I'm doing something wrong but I does a test program for you:

-------------------------------------------------------------------------------------------------------------

Execute this code:

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;

public class JXTableFilterChooser extends JDialog {

private final static String [] TOTO = new String[]{"Test", "Test2", "Blabla", "SwingX", "BUG", "RockOn", "First", "Third"};

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);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

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() {

@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});

addItem = new JButton("To Right");
addItem.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
int[] indices = hideList.getSelectedIndices();

// On commence par la fin car on supprime les éléments donc les index change
// Il faut commencer par le plus grand index
for (int i = indices.length - 1; i >= 0; i--) {
int index = hideList.convertIndexToModel(indices[i]);
shownListModel.addElement(hideListModel.elementAt(index));
hideListModel.remove(index);
}

repaint();
}
});

removeItem = new JButton("ToLeft");
removeItem.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
int[] indices = shownList.getSelectedIndices();

// On commence par la fin car on supprime les éléments donc les index change
// Il faut commencer par le plus grand index
for (int i = indices.length - 1; i >= 0; i--) {
int index = shownList.convertIndexToModel(indices[i]);
hideListModel.addElement(shownListModel.elementAt(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();
}

/**
* @param args
*/
public static void main(String[] args) {
JXTableFilterChooser test = new JXTableFilterChooser("SwingX Bug Test", TOTO);
test.setVisible(true);
}

}

-------------------------------------------------------------------------------------------------------------

The bug:

Select all element on the right.... move them to the left with the arrow
Now, do the same thing... select All Left and move to Right

Now select an element of the right list...

You should have this stacktrace ... hummm should not but I do have :D

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 8
at org.jdesktop.swingx.decorator.ShuttleSorter.mapTowardModel(ShuttleSorter.java:106)
at org.jdesktop.swingx.decorator.Filter.convertRowIndexToModel(Filter.java:116)
at org.jdesktop.swingx.decorator.FilterPipeline.convertRowIndexToModel(FilterPipeline.java:430)
at org.jdesktop.swingx.decorator.DefaultSelectionMapper.convertToModel(DefaultSelectionMapper.java:208)
at org.jdesktop.swingx.decorator.DefaultSelectionMapper.mapTowardsModel(DefaultSelectionMapper.java:225)
at org.jdesktop.swingx.decorator.DefaultSelectionMapper.access$000(DefaultSelectionMapper.java:38)
at org.jdesktop.swingx.decorator.DefaultSelectionMapper$2.valueChanged(DefaultSelectionMapper.java:284)
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 javax.swing.JList.setValueIsAdjusting(JList.java:2110)
at javax.swing.plaf.basic.BasicListUI$Handler.mouseReleased(BasicListUI.java:2778)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
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 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)

Thanks for help!

Kleopatra

you discovered a bug:

https://swingx.dev.java.net/issues/show_bug.cgi?id=855

Thanks for the detailed example and description, I love that - as it
makes my life so much easier :-)

In the issue I summarized what's happening. Need to think about a
solution a bit longer.

CU
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

Kleopatra schrieb:
>
> In the issue I summarized what's happening. Need to think about a
> solution a bit longer.
>

should be fixed now (as of version 1.4 of DefaultSelectionMapper).
Probably not yet full safe but your example is running okay.

CU
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

grattier
Offline
Joined: 2008-01-30

I saw that you closed the ticket for "No complains" but with the latest weekly build:

swingx-2008_05_13-bin

I still have the bug... not you ????

Kleopatra

jdnc-interest@javadesktop.org schrieb:
> I saw that you closed the ticket for "No complains" but with the latest weekly build:
>
> swingx-2008_05_13-bin
>
> I still have the bug... not you ????
>

No, here it's working (I'm not quite as arrogant as to closing a bug ;-)
Hmm ... where did you get that version? Not entirely convinced that the
automatic copying on the swinglabs.org really happens with the latest
weekly, directly from Hudson should be okay (Jan?). Anyway, somebody
please check the version (I'm off and away any minute now) of the
DefaultSelectionMapper: 1.4, committed 9. May, contains the fix. If
that's the case and you still see the exception on selecting an item
please re-open the issue - next effort to dig and fix must be postponed
to after my vacation, sorry.

CU
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

grattier
Offline
Joined: 2008-01-30

Humm...

I tried: swingx-2008_05_18-bin from Hudson .. it's working

I tried: swingx-2008_05_25-bin .. from https://swingx.dev.java.net/servlets/ProjectDocumentList?folderID=6869&e... .. it's working

So the bugs was in: swingx-2008_05_13-bin (and previous) also from https://swingx.dev.java.net/......

Thanks!

Kleopatra

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;
>
> /**
> *
> *

Title: JXTableFilterChooser.java

> *

Description: Allow the user to choose which value is filtered (shown)

> *

Copyright: Copyright (c) 2008

> * @version $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(){
> @Override
> public void actionPerformed(ActionEvent e) {
> setVisible(false);
> }
> });
>
> addItem = new JButton(">");
> addItem.addActionListener(new ActionListener(){
> @Override
> public void actionPerformed(ActionEvent e) {
>
> }
> });
>
> removeItem = new JButton("<");
> removeItem.addActionListener(new ActionListener(){
> @Override
> 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@jdnc.dev.java.net
> For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

grattier
Offline
Joined: 2008-01-30

Ok, I'll try with a weekly build and updated Java and If I still have the bug, I'll try to create a demo project doing the error for you.

grattier
Offline
Joined: 2008-01-30

Here is a part of my code:

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);

removeItem = new JButton("Remove");
removeItem.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
int index = shownList.getSelectedIndex();

index = shownList.convertIndexToModel(index);
shownListModel.remove(index);

repaint();
}
});

pack();
}
}

Thanks for help

Message was edited by: grattier

Message was edited by: grattier

Message was edited by: grattier