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
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
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.
Joined: Jan 29, 2001
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