aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable in a JScrollPane (last column heading of table always cut) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable in a JScrollPane (last column heading of table always cut) " Watch "JTable in a JScrollPane (last column heading of table always cut) " New topic
Author

JTable in a JScrollPane (last column heading of table always cut)

mark I thomas
Ranch Hand

Joined: Apr 07, 2008
Posts: 86
I have a JTable inside a JScrollPane. I found that, regardless of the number of columns, the last column heading of the table is always one pixel cut from the right end. Even I reduce the number of columns it does not help. All other columns look fine in width

How can I solve this problem ?

*****************************************
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(1300, 500));
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
table.getColumnModel().getColumn(1).setPreferredWidth(100);
table.getColumnModel().getColumn(2).setPreferredWidth(100);
table.getColumnModel().getColumn(3).setPreferredWidth(100);
table.getColumnModel().getColumn(4).setPreferredWidth(100);
table.getColumnModel().getColumn(5).setPreferredWidth(100);
....

JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(table);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
...

******************************************
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2200
    
    7
I don't see a problem using JDK6_7 on XP.

If you need more help post your SSCCE demonstrating the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable in a JScrollPane (last column heading of table always cut)