Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes JScrollpane problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollpane problem" Watch "JScrollpane problem" New topic
Author

JScrollpane problem

Maarten Vergouwen
Ranch Hand

Joined: Jan 12, 2004
Posts: 60
I'm having trouble getting a JScrollpane to do what it is supposed to do, ie enable scrolling.

What I want to do is add scrolling to a JList. I have coded the following:


jScrollPane1 = new javax.swing.JScrollPane();


Then I add items to the list using:


When I then add items to the list, I see them added just fine, but once the entire list is filled on screen, no scrollbar appears though items continue to be added.

Can anyone tell me what could be wrong?

tia,
Maarten
Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
Hi there,

Why not try an easier approach to getting your JList to scroll.

JScrollPane myScrollPane = new JScrollPane(myList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

That's all you need.

Give me a shout if you need more help,
Cheers,
Rachel
Maarten Vergouwen
Ranch Hand

Joined: Jan 12, 2004
Posts: 60
Thank you for your help Rachel.
After seeing your bit of code work fine, my error turned out to be far more elementary than I'd feared (unreachable code because of a careless comment.... highly embarrasing ).

rgds,
Maarten
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JScrollpane problem