aspose file tools
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 The Software Craftsman this week in the Agile 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="" target="_blank" rel="nofollow"></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.
Don't get me started about those stupid light bulbs.
subject: JPanel & JScrollPane