File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to Add Scroll bars to a frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to Add Scroll bars to a frame" Watch "How to Add Scroll bars to a frame" New topic
Author

How to Add Scroll bars to a frame

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
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


SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
kyle amburn
Ranch Hand

Joined: Jul 29, 2001
Posts: 64
Are you adding the JFrame to the JScrollPane???
This is hou you use a JScrollPane:

Kyle
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Does it mean that we have to use Panel only for adding scrollPane to a Frame
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

This should also work. Just add the following lines after all the components have been added to your JFrame -


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
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
 
subject: How to Add Scroll bars to a frame