Layout manager in a scrollpane.

Hi,

I have a JTable, which is sitting in a scrollpane in a JInternalFrame. The scroller works fine, in that scrollbars appear when the frame is made smaller than the table. So its a bit like this...

paramsTable = JTable(etc)...

iframeParams = JInternalFrame();

scroller = JScrollPane();

scroller.add(paramsTable);

scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

iframeParams.add(scroller);

However, if the frame is made larger than the table, then the table just sits in the extreme top left corner of the frame. What I would like is for it allways to be centred, so presumably I need to have some sort of layout manager in there? If I try to use 'setLayout' on the scrollpane I get an exception. What should I do? Should I somehow be putting the table into JPanel with the right layout manager and then putting that into the scrollpane (but just trying that means the table is invisible..). I need to sort this out as I'm going to be putting other components there eventually so I need to work out how to manage the layout.

Cheers,

Arwel

[1244 byte] By [Arwela] at [2007-11-27 7:39:29]
# 1
Which exception?(And did you know that we have a Swing forum?)
CeciNEstPasUnProgrammeura at 2007-7-12 19:20:11 > top of Java-index,Java Essentials,New To Java...
# 2
>>Which exception?java.lang.ClassCastException: layout of JScrollPane must be a ScrollPaneLayout>>(And did you know that we have a Swing forum?)Er, yes. But I'm a newbie and I reckoned this must be a dead simple newbie question!
Arwela at 2007-7-12 19:20:11 > top of Java-index,Java Essentials,New To Java...
# 3
New thread here: http://forum.java.sun.com/thread.jspa?threadID=5184417
CeciNEstPasUnProgrammeura at 2007-7-12 19:20:11 > top of Java-index,Java Essentials,New To Java...