• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPanel & JScrollPane

 
S.Subhash Chandran
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic