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 Problem in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in JTable" Watch "Problem in JTable" New topic

Problem in JTable

Vishal Methi
Ranch Hand

Joined: Jan 14, 2004
Posts: 52
Is it possible in JTable to change the size of a particular row. Actually i have with 10 rows and 10 columns and i want the size of 4th and 8th smaller than other rows......... plz suggest me asap...........
Jason Steele
Ranch Hand

Joined: Apr 25, 2003
Posts: 100
you would have to extend JLabel and implement DefaultTableModel
or extend AbstractTableModel. Preferrable the second option.

Then in the getTableCellRendererComponent method, test to see if you are in row 4 or 8...or better yet row % 4 == 0. If it is, then call setPreferredSize on that label to be the size you desire.

Good Luck!

An egg is a chicken's house!
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
JTable.setRowHeight(row, rowHeight) is another possibility.

SCJP2. Please Indent your code using UBB Code
I agree. Here's the link:
subject: Problem in JTable
It's not a secret anymore!