• 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

JTable Problem - Urgent !!!!

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a JTable inside a JScrollPane which is added to a JPanel and this panel is added to a JTabbedPane. tabbedPane is added to a JPanel.
I dynamically populate JTable from a sql query and which has a large number of columns (around 30-40).
The problem is all columns are not visible in the JTable, though I scroll horizontal scrollBar to right. I tried to change the size of tabbedPane and panel... still didn't work.
Anybody know solution for this.
Appreciate if you could reply soon.
Thanks,
-SH
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
check out ur scrollpane.it may be to do with the size of the Scrollpane.Also,in scrollpane ,u got a constructor which specifies scrollbar policy.
JScrollPane(int vsbPolicy, int hsbPolicy)
try it out..
Raj
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Seema,
Let me see if I got this straight. Initially your table has small number of columns, if any, and then you populate it and it gets 30-40 columns of data.
I would think that the ScrollPane probably doesn't revalidate after all the columns are added (assuming of course that your panels are sizing correctly). You might try and call revalidate on the ScrollPane after do something on your table that changes it size (less rows or more/less columns). The ScrollPane uses its size versus the preferredSize of its' child to calculate the size of its scrollBar.
Regards,
Manfred.
 
Seema Hanji
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all of your responses.
I solved this problem. I was setting column widths using TableColumn.setMinWidth(). I replaced this with TableColumn.setPreferredWidth() and all columns are visible now.
-SH
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic