A JTable inside a JScrollPane automatically adjusts its width to the size of the viewport. Can I fix the width of the table to something larger, and enable the horizontal scroll bar to work instead?

Joseph Shelby

The JTable has a method, setAutoResizeMode(int), that defines the resize policy based on 5 constants, also defined in JTable :

AUTO_RESIZE_OFF, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_SUBSEQUENT_COLUMNS,
AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS

AUTO_RESIZE_OFF will disable all resizing and enable the horizontal scroll bar of the parent JScrollPane.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact