tags:

views:

48

answers:

2

Hello,

i want to display a jtable with the feature, that if there is not enough space left on the screen the columns first start to shrink (and display less info) and then start to disappear. The info contained in the removed column for the selected row has to be displayed in a details view.

Is there a component in any swing component library (may it opensource or commercial) which offers these features?

Thanks in advance,

Nils

+1  A: 

You could call JTable's setAutoResizeMode(int) with the value JTable.AUTO_RESIZE_ALL_COLUMNS. The default resize mode is AUTO_RESIZE_SUBSEQUENT_COLUMNS, which will preserve the total width of the table (i.e. if you expand one column the whole table becomes wider). With AUTO_RESIZE_ALL_COLUMNS the table size should never increase in width beyond the bounds of the JScrollPane; i.e. you should never see a horizontal scroll bar.

Obviously this doesn't solve the part of your problem concerning auto-hiding columns when they become sufficiently small.

Adamski
Just to add on to @Adamski, this is a good starting point, and it would be trivial to add some additional logic of your own to control the autohiding etc inside of event listeners.
bguiz
+1  A: 

Perhaps the Jide components offer smth. like that. It seems to me you want to have some kind of master detail view with the table as master!?

Have a look here: http://www.artima.com/forums/flat.jsp?forum=276&thread=156018

It is not mentioned which component exactly provides the master detail view, but perhaps someone here already used it?

Markus Meierhöfer