Board index » jbuilder » JScrollPane for JTable in a GridBagLayout
Oliver
![]() JBuilder Developer |
JScrollPane for JTable in a GridBagLayout2005-04-01 10:26:20 PM jbuilder20 Hello, i am having some trouble in implementing a JScrollPane for a JTable (im showing database records there via SQL). The JScrollPane is placed on a JPanel which in turn resides on my main frame. My main Frame has a GridBagLayout.The JPanel has also a GridBagLayout. I am using table.setSize(...) to make the JTable bigger than the screen. This works ok. Now im using table.setPreferredScrollableViewportSize(t); where t is a region inside the screen (smaller than the JTable). Now: how big do i have to make the JScrollPane? 1) if i make the JScrollPane as big as the JTable, then there appears a horizontal ScrollBar (scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); but it has no knob for scrolling (i assume because they have the same size, the system thinks its not necessary) 2) if i make the JScrollPane as big as t (inside the screen), the JTable becomes also smaller (which i do not want - i want the JTable to be bigger than the screen). Does somebody have a hint how i can get a horizontal scrollbar which works for a JTable which is bigger than the screen? thanks Oliver |