Name: ddT132432 Date: 10/19/2001
java version "1.3.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)
The problem
-----------
I am using the JTable class for the first time. I always instantiate the class
as a child of a JScrollBar object:
JTable jMyTable = new JTable();
JScrollPane jMyScrollPane = new JScrollPane(jMyTable);
The default auto resize mode for a table is JTable.AUTO_RESIZE_SUBSEQUENT_COLUMN.
It took me some time to realize that I had to set the this value to
JTable.AUTO_RESIZE_OFF to make the JSCrollPane's horizontal scrollbar
visible. I had been setting the minimum and preferred widths of all columns
in my tables and wondering why the scroll pane's horizontal scrollbar was not
being made visible when the viewport for the table was smaller than the
preferred width of the table.
Solutions
---------
I suggest that the horizontal scrollbar is made visible any time the
preferred size of a JTable is greated than the size of the JSCrollPane's
Viewport, regardless of the table's auto resize mode.
An alternative solution would be not that horizontal scrolling only works when
a table's auto resize mode is set to JTable.AUTO_RESIZE_OFF in the API and the
JTable tutorial, which currently doesn't provide an example of using the table
with a horizontal scrollbar.
A second alternative is to set the default table auto resize mode to
JTable.AUTO_RESIZE_OFF always.
A third alternative is to set the default table auto resize mode to
JTable.AUTO_RESIZE_OFF only when it is a child of a JScrollPane.
Also please see http://developer.java.sun.com/developer/bugParade/bugs/4105163.html
(Review ID: 134095)
======================================================================