File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollpane problem

 
Maarten Vergouwen
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 434
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic