Skip to main content

ArrayIndexOutOfBoundsException in ShuttleSorter

3 replies [Last post]
fester
Offline
Joined: 2006-11-06
Points: 0

Hi,

I'm using JXTable with Glazedlists. This usally goes well, but sometimes i get the following stack trace:

<br />
java.lang.ArrayIndexOutOfBoundsException: 12<br />
	at org.jdesktop.swingx.decorator.ShuttleSorter.mapTowardModel(ShuttleSorter.java:101)<br />
	at org.jdesktop.swingx.decorator.Filter.convertRowIndexToModel(Filter.java:115)<br />
	at org.jdesktop.swingx.decorator.FilterPipeline.convertRowIndexToModel(FilterPipeline.java:430)<br />
	at org.jdesktop.swingx.JXTable.convertRowIndexToModel(JXTable.java:1271)<br />
	at com.traficon.app.tms.eventstack.EventStackTable.getSelectedItem(EventStackTable.java:104)<br />
	at com.traficon.app.tms.eventstack.EventStack.getSelectedItem(EventStack.java:1190)<br />
	at com.traficon.app.tms.eventstack.EventStack.access$1000(EventStack.java:71)<br />
	at com.traficon.app.tms.eventstack.EventStack$ConfirmButtonTableListSelectionListener.valueChanged(EventStack.java:1399)<br />
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)<br />
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:137)<br />
	at javax.swing.DefaultListSelectionModel.setValueIsAdjusting(DefaultListSelectionModel.java:668)<br />
	at org.jdesktop.swingx.decorator.DefaultSelectionMapper.setEnabled(DefaultSelectionMapper.java:149)<br />
	at org.jdesktop.swingx.JXTable.tableChanged(JXTable.java:1396)<br />
	at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:280)<br />
	at ca.odell.glazedlists.swing.EventTableModel.listChanged(EventTableModel.java:144)<br />
	at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter$ListEventFormat.fire(ListEventAssembler.java:869)<br />
	at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter$ListEventFormat.fire(ListEventAssembler.java:861)<br />
	at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher$SubjectAndListener.firePendingEvent(SequenceDependenciesEventPublisher.java:435)<br />
	at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher.fireEvent(SequenceDependenciesEventPublisher.java:334)<br />
	at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter.fireEvent(ListEventAssembler.java:855)<br />
	at ca.odell.glazedlists.event.ListEventAssembler$AssemblerHelper.commitEvent(ListEventAssembler.java:389)<br />
	at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:226)<br />
	at ca.odell.glazedlists.BasicEventList.add(BasicEventList.java:125)<br />
	at com.traficon.app.tms.eventstack.EventStack.doAddNewEvent(EventStack.java:378)<br />
	at com.traficon.app.tms.eventstack.EventStack.access$400(EventStack.java:71)<br />
	at com.traficon.app.tms.eventstack.EventStack$1$1.run(EventStack.java:238)<br />
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)<br />
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)<br />
	at com.traficon.app.tms.Main$3$1.dispatchEvent(Main.java:409)<br />
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)<br />
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)<br />
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)<br />
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)<br />
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)<br />
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)<br />

Is there somebody who might have a clue why this is happening?

This is the code I use to get the selected item (it is in a subclass of JXTable):

<br />
	public EventStackItem getSelectedItem()<br />
	{<br />
		EventStackItem item = null;<br />
		EventTableModel tableModel = getModel();<br />
		int index = getSelectedRow();<br />
		if (index != -1 && index < tableModel.getRowCount())<br />
		{<br />
			item = tableModel.getElementAt( convertRowIndexToModel( index ) );<br />
		}<br />
		return item;<br />
	}<br />

The table is highly dynamic, so maybe I'm having some kind of threading issue here?

regards,

Wim

Reply viewing options

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

Hi Fester --

To use JXTable with Glazed Lists, you'll probably want
to use Glazed Lists' provided ListSelectionModel. You
should also consider using EventListJXTableSorting to
configure Glazed Lists to handle the table sorting rather
than the JXTable.

You can read up on EventSelectionModel here:
http://publicobject.com/glazedlists/wiki/index.php?title=TutorialChapter5

To use EventListJXTableSorting, use a SortedList as
the source to your EventTableModel, then make this call:
EventListJXTableSorting.install(sortedList, table);
This makes it so that Glazed Lists does the sorting
rather than SwingX. The main benefit of this is that
for highly dynamic tables, your performance will be
significantly higher. It also plays nicely with the locking
if you're EventLists are accessed by multiple threads.

Cheers,
Jesse

On 7/10/07, jdnc-interest@javadesktop.org wrote:
> Hi,
>
> I'm using JXTable with Glazedlists. This usally goes well, but sometimes i get the following stack trace:
> [code]
> java.lang.ArrayIndexOutOfBoundsException: 12
> at org.jdesktop.swingx.decorator.ShuttleSorter.mapTowardModel(ShuttleSorter.java:101)
> at org.jdesktop.swingx.decorator.Filter.convertRowIndexToModel(Filter.java:115)
> at org.jdesktop.swingx.decorator.FilterPipeline.convertRowIndexToModel(FilterPipeline.java:430)
> at org.jdesktop.swingx.JXTable.convertRowIndexToModel(JXTable.java:1271)
> at com.traficon.app.tms.eventstack.EventStackTable.getSelectedItem(EventStackTable.java:104)
> at com.traficon.app.tms.eventstack.EventStack.getSelectedItem(EventStack.java:1190)
> at com.traficon.app.tms.eventstack.EventStack.access$1000(EventStack.java:71)
> at com.traficon.app.tms.eventstack.EventStack$ConfirmButtonTableListSelectionListener.valueChanged(EventStack.java:1399)
> 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.JXTable.tableChanged(JXTable.java:1396)
> at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:280)
> at ca.odell.glazedlists.swing.EventTableModel.listChanged(EventTableModel.java:144)
> at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter$ListEventFormat.fire(ListEventAssembler.java:869)
> at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter$ListEventFormat.fire(ListEventAssembler.java:861)
> at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher$SubjectAndListener.firePendingEvent(SequenceDependenciesEventPublisher.java:435)
> at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher.fireEvent(SequenceDependenciesEventPublisher.java:334)
> at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter.fireEvent(ListEventAssembler.java:855)
> at ca.odell.glazedlists.event.ListEventAssembler$AssemblerHelper.commitEvent(ListEventAssembler.java:389)
> at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:226)
> at ca.odell.glazedlists.BasicEventList.add(BasicEventList.java:125)
> at com.traficon.app.tms.eventstack.EventStack.doAddNewEvent(EventStack.java:378)
> at com.traficon.app.tms.eventstack.EventStack.access$400(EventStack.java:71)
> at com.traficon.app.tms.eventstack.EventStack$1$1.run(EventStack.java:238)
> at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
> at com.traficon.app.tms.Main$3$1.dispatchEvent(Main.java:409)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
> at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
> [/code]
>
> Is there somebody who might have a clue why this is happening?
>
> This is the code I use to get the selected item (it is in a subclass of JXTable):
> [code]
> public EventStackItem getSelectedItem()
> {
> EventStackItem item = null;
> EventTableModel tableModel = getModel();
> int index = getSelectedRow();
> if (index != -1 && index < tableModel.getRowCount())
> {
> item = tableModel.getElementAt( convertRowIndexToModel( index ) );
> }
> return item;
> }
> [/code]
>
> The table is highly dynamic, so maybe I'm having some kind of threading issue here?
>
> regards,
>
> Wim
> [Message sent by forum member 'fester' (fester)]
>
> http://forums.java.net/jive/thread.jspa?messageID=225956
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
> For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
>
>

--
Climate change should be your #1 political issue.
http://www.youtube.com/watch?v=zORv8wwiadQ

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

fester
Offline
Joined: 2006-11-06
Points: 0

Thank you Jesse, it seems to be ok now.

kschaefe
Offline
Joined: 2006-06-08
Points: 0

Is it possible to provide a test case? I'm not finding the stack trace at all helpful in this instance.

Karl