File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTable AUTO_RESIZE_OFF and extra column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable AUTO_RESIZE_OFF and extra column" Watch "JTable AUTO_RESIZE_OFF and extra column" New topic

JTable AUTO_RESIZE_OFF and extra column

Mikko Kohtamäki
Ranch Hand

Joined: Dec 13, 2008
Posts: 112
Hi, had problem to fill the extra space of JTable when there are too few columns to fill the preferredScrollableViewportSize, when JTable's autoResizeMode is AUTO_RESIZE_OFF.

This example overrides configureEnclosingScrollPane() in JTable to rebuild whole new view.

JTableViewFiller listens LinkTable when it resizes to get new width for extra JTableHeader.

JTableViewFiller delegates LinkTable's Scrollable interface methods.

RendererPanel has a preferred size set that is updated, it has CellRendererPane which paints the extra JTable to extra space.

getHeaderViewFiller() is where you get the header view for JScrollPane.

I have a table that has visible row count, rows that dont exist in model, etc. Here I tried to do short and working example for JTable.
PROBLEM is that when I resize the column to right of actual table and if JScrollPane has defaults in ScrollBarPolicy (AS_NEEDED),
then horizontal scroll bar is FLICKERING... how to remove this behaviour or is this good at all ???

Will I set ScrollBarPolicies temporarely when resizing and table's width is less than preferredScrollableViewportSize.width

Try it, many thanks :)

I agree. Here's the link:
subject: JTable AUTO_RESIZE_OFF and extra column
It's not a secret anymore!