Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPanel with null layout in JScrollPane

843806Aug 7 2007 — edited Aug 7 2007
Hellow =)

well.. it's pretty much as the title says
I've made a JPanel.. in which I let the user add some buttons
I've set that panel to null layout so I could nicely order them buttons (tried with girdbaglayout but couldn't figure that out)

and now I need scrollbars in the panel for when the user adds more buttons.. than the panel can show
I've googled some aruond and eventually got the scrollbars to show and they even seem to work..
but when I add more buttons the scrollbars don't change to be able to scroll around more.. they just stay the same size as they were when the applet launches

here's how I configured the panel and scrollpane..
	JPanel chartPanel = new JPanel();
	JScrollPane scroll = new JScrollPane(chartPanel);

		chartPanel.setLayout(null);
		chartPanel.setPreferredSize(new Dimension(getWidth(), getHeight()));
		scroll.setBounds(2, 2, getWidth(), getHeight());
		
		add(scroll);
Message was edited by:
Nizzle
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 4 2007
Added on Aug 7 2007
11 comments
476 views