File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Add Scroll bars to a frame

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to add a scrollpane to my frame and get the exception as trying to add window to a container
I don't know how to add scroll bar to a container
Can any one pls give me some sample code to start
I will be highly thankful
 
kyle amburn
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you adding the JFrame to the JScrollPane???
This is hou you use a JScrollPane:

Kyle
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it mean that we have to use Panel only for adding scrollPane to a Frame
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should also work. Just add the following lines after all the components have been added to your JFrame -
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying
but can you tell me if I make my content pane as JScrollpane then which layout should I use
Can I use Box Layout in that case?
I try to add on this pane and nothing comes on frame, neither scroll bar not components
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic