« Return to Thread: EventListJXTableSorting

Re: EventListJXTableSorting

by Steve Newell :: Rate this Message:

Reply to Author | View in Thread

James,

Thanks for you response.  Indeed, your #1 below solved the lockup problem, and #3 seemed to solve my other problems, EXCEPT...

Even though I specified a Comparator in the SortedList constructor, when I install an EventListJXTableSorting the list is unsorted initially.  If I do not install it, the list is sorted properly.  That leads me to the $64K question...

Do I need the EventListJXTableSorting installed if I use a JXTable?  

From my reading of the wiki, I understood that if I was going to use a JXTable instead of a JTable,  and I wanted sorting, I had to either install EventListJXTableSorting OR use a TableComparatorChooser.

My experience leads me to believe that this is not the case.  It appears that if I create an EventTableModel with a SortedList and create a JXTable with the EventTableModel, everything works.

I'm sure I'm missing something, and I appreciate your help in clarifying all this.

Steve

Steve,

1. Your test class fails to work reliably because you're not building /
showing your Swing components on the EDT. Wrap everything in your main
method in a Runnable and post it to the EDT like so:

SwingUtilities.invokeLater(new Runnable() {
   public void run() {
      GlazedListJXTableProblem frame = null;

      if( args.length > 0 ) {
         frame = new GlazedListJXTableProblem( args[ 0 ] );
      } else {
         System.out.println( "specify List as first parameter: { JTable |
JXTableJXSorting | JXTableGLSorting }");
         System.exit( 0 );
      }

      frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      frame.setVisible( true );
   }
});


2. I read the class doc for EventListJXTableSorting and it explains how to
use it:

a) Create a {@link SortedList} and {@link EventTableModel} that depends on
that {@link SortedList}.
b) Create a {@link JXTable} using the {@link EventTableModel} as its model.
c) Run the {@link EventListJXTableSorting#install} method to bind the {@link
JXTable}'s headers to the {@link SortedList}'s {@link Comparator}.

Notice that it says nothing about TableComparatorChooser. In fact, later in
the class doc it even mentions this:

"The behaviour of multiple column sorting in JXTable is not particularly
flexible. For different configuration options, consider using a {@link
TableComparatorChooser} instead of {@link EventListJXTableSorting}."


3. Removing the call to TableComparatorChooser.install seems to produce the
behaviour you are looking for.


4. I was using the latest jar of GL and the latest jar of swingx and I never
saw two sort icons like the snapshots you pointed at. That said, I'd guess
they are caused by having two different table sorting mechanisms in play
(TableComparatorChooser and EventListJXTableSorting).

Hope this helps,

James

 « Return to Thread: EventListJXTableSorting