hoe to display scrollbar over the panel

hi,

i added jpanel object inside a jframe objects container as follows.

setSize(570,470);

panel=new JPanel();

panel.setLayout(null);

Toolkit tk=Toolkit.getDefaultToolkit();

Dimension d=tk.getScreenSize();

panel.setSize(d.width,d.height);

JScrollPane sp=new JScrollPane(panel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );

Container c=getContentPane();

c.add(sp,"Center");

here my panel size is more than the frame size. but my panel is not scrolling. i need scrollbars to display. how can i do this ?

thankx in advance.

[632 byte] By [vchandramoulia] at [2007-9-30 0:16:04]
# 1
Hi,try using setMinimumSize() instead. Should work.
imaginnera at 2007-7-16 4:44:41 > top of Java-index,Archived Forums,Swing...
# 2
> panel.setSize(d.width,d.height);Scrollbars appear when the preferredSize() of the panel is greater than the size of the scrollpane. Use:panel.setPreferredSize(...);
camickra at 2007-7-16 4:44:41 > top of Java-index,Archived Forums,Swing...