• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to change scrollable viewport size dynamicaly in JTable

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"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
reply
    Bookmark Topic Watch Topic
  • New Topic