[Advanced-java] Horizontally Scroll in JTable (Wrapped byJScrollPane)

Michiel Westland mwestland at vda.nl
Wed Apr 2 07:02:29 2003


Dear Alvin,


For example, use:
  table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

to set autoresize off and
  table.getColumnModel().getColumn(2).setPreferredWidth(50);

to set the width of the third colummn (index 2) to 50 pixels.


Michiel Westland


-----Oorspronkelijk bericht-----
Van: advanced-java-bounces@lists.xcf.berkeley.edu
[mailto:advanced-java-bounces@lists.xcf.berkeley.edu]Namens Alvin Wang
Verzonden: dinsdag 1 april 2003 21:39
Aan: advanced-java@lists.xcf.berkeley.edu
Onderwerp: [Advanced-java] Horizontally Scroll in JTable (Wrapped
byJScrollPane)


Hi! I am writing a JTable with a lot of columns. Java will try to shrink the
columns to display all of them. So some data will be displayed as "-12...".
The user has to widen the column manually to see the data. It is not
convenient. My JTable is wrapped by a JScrollPane, so I wanto let JTable
just use whatever width it needs for each column to display the data, and
the user can scroll horizontally. Can any gurus tell me how to do it? I
think the main problem is how to disallow JTable from shrinking.

Thanks!

_______________________________________________
Advanced-java mailing list
Advanced-java@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java