Show Column Header on dragging column

i implement the code in GroupableHeader and try to enable the reordering allowed but i have two problems:

1: When dragging a column the header don´t see over the column
2: How restrict the dragged area of the column to prevent the column exit of the columnGroup

I don´t understand why the header don´t see on column dragging, i read the table header api but did not find any solution. Any ideas for solving these problems?


My predecessor also thought that using code they copied off the internet was a good idea...fortunately for my company, I don't

I spent about 4 weeks of my spare time digging through the implementation and comparing it with the default BasicTableHeaderUI figuring out how to reinstate...

  • Column ordering, including, limiting the grouped columns to there group
  • Row sorting
  • Various other bits and pieces

This is a incomplete solution, as I've not yet quite got to the point where when you drag a group and have it show all the columns in the group, but that's within the TableUI

Draggable column groups

Unfortunately, I can't paste the code, it's over the 3000 character limit, but you can grab a copy from here


A bit more complete solution: JBroTable.

It's based on MadProgrammer's answer. It restricts column dragging out of the group too. And brings some extra features:

  • Arbitrary number of rows
  • Natural API for model creation
  • Generic support for other L&Fs (Windows system L&F, GTK, Nimbus etc.)

Sample model creation:

IModelFieldGroup groups[] = new IModelFieldGroup[] {
  new ModelFieldGroup( "A", "A" )
    .withChild( new ModelField( "B", "B" ) )
    .withChild( new ModelField( "C", "C" ).withRowspan( 2 ) ), // Custom rowspan set.
  new ModelFieldGroup( "D", "D" )
    .withChild( new ModelField( "E", "E" ) )
    .withChild( new ModelField( "F", "F" ) ),
  new ModelField( "G", "G" ),
  new ModelFieldGroup( "H", "H" )
    .withChild( new ModelFieldGroup( "I", "I" )
                  .withChild( new ModelField( "J", "J" ) ) )
    .withChild( new ModelField( "K", "K" ) )
    .withChild( new ModelFieldGroup( "L", "L" )
                  .withChild( new ModelField( "M", "M" ) )
                  .withChild( new ModelField( "N", "N" ) ) )
};

Result:

Result

Animated demo (2.5M)

Update:

Added drawing of the whole dragged columns group.