This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes how to change scrollable viewport size dynamicaly in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to change scrollable viewport size dynamicaly in JTable" Watch "how to change scrollable viewport size dynamicaly in JTable" New topic
Author

how to change scrollable viewport size dynamicaly in JTable

cs sakthi
Greenhorn

Joined: May 11, 2001
Posts: 15
Hai Everybody,
I want to change the scrollable viewport size of a JTable dynamically occording to the number of rows. it accepts the setting size i know this when the get method call returns the size of finally set size but the panel didn't get affected!!
Thanks,
Sakthi.
Rajan
Greenhorn

Joined: Jun 19, 2001
Posts: 6

hi cs,
You can set your scrollableviewport size.
create the dimension accoding to number of the row and width of your table.
Dimension dim = new Dimension(row size, width)
table.setPreferredScrollableViewportSize(dim).
or
table.setPreferredScrollableViewportSize(table.getPreferredSize()).

or
Dimension size = table.getPreferredScrollableViewportSize();
table.setPreferredScrollableViewportSize (new Dimension(Math.min(getPreferredSize().width, size.width), size.height);
Hope this will meet your requirement.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

"Rajan"
javaranch receives a lot of users everyday and some with surprisingly similar names. Your name is not is accordance
with the javaranch guidelines
could you please take a moment and re-register.
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to change scrollable viewport size dynamicaly in JTable
 
Similar Threads
JTable AUTO_RESIZE_OFF and extra column
My JTable is a bit confused
What listener for JTable header column size change
JTable
Unable to display the JTable