The moose likes Swing / AWT / SWT and the fly likes JPanel & JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel & JScrollPane" Watch "JPanel & JScrollPane" New topic

JPanel & JScrollPane

S.Subhash Chandran

Joined: Dec 31, 2002
Posts: 27
I have a class which extends JPanel. 2D images are drawn on it dynamically, as are components added to it. The problem is that when an instance of this object is added to the window:
getContentPane().add(new JScrollPane(myPanel));
I don't get the scroll bars when components are added to it dynamically below the viewport. Help!!!

Subhash Chandran S<br /><a href="http://www.indiwiz.com/" target="_blank" rel="nofollow">http://www.indiwiz.com/</a>
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

You'll have to modify the preferred size of the component when you add shapes. You'll also need to call parent.validate() to force the scroll pane to redraw...

I think I have an example here.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
jQuery in Action, 2nd edition
subject: JPanel & JScrollPane
Similar Threads
JPanel to scollable panel
Swing application using netBeans IDE
JScrollPane knob won't change size
Adding ScrollPane to JPanel
Increasing the size of the Panel