2

I have a JTable that is filled dynamically. It has only two columns, the first is a boolean value and the second is a string.

The problem is that when I select a row in the string column, the table autoscrolls to the right hiding the first column.

How do I change this behaviour?

If I disable autoscroll, the user is not able to scroll to the bottom through the arrow keys.

Any ideas?

Thanks in advance.

4

1 回答 1

1

Call:

jscrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

which will make sure no horizontal JScrollBar is created for the JScrollPane.

Perhaps also need to ensure the JScrollPane fits the JTable horizontally via:

table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane jscrollpane = new JScrollPane(table);
于 2013-07-30T17:45:25.770 回答