File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable Problem - Urgent !!!!

 
Seema Hanji
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Rajendar Goud
Ranch Hand
Posts: 220
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic