• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get scroll bars to appear when adding a JList to a GUI

 
Arend van der Kolk
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you add the list directly to the frame like you do with "frame.getContentPane().add(BorderLayout.NORTH, list);" then you don't get the scrollbar.

Arend
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't post unrelated questions on previous threads. Fortunately I can split you into a new thread altogether, which will be on the GUIs forum.

Have you read about Scroll Panes? You would need a scroll pane in order to see scroll bars, and the component inside the scroll pane may need to enlarge before the scroll bars appear.
 
Arend van der Kolk
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ritchie,

in that case you can delete my reply, it was just a statement. Because i tested that code i thought let me add this comment. So, no replying to old posts i understand now.
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No need to delete anything; your post has vanished from the old thread.
More important: did you get the scroll pane to work?
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Don't add the JList to the JFrame.

You need to add the JList to the JScrollPane and then the scroll pane to the JFrame:


Read the section from the Swing tutorial on How to Use Lists for more information.

Keep a link to the tutorial handy for Swing basics.
 
Arend van der Kolk
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

yes, i did thanks. On to the next assigment, a Beatbox (haha, all beginners go through the same path)
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arend van der Kolk wrote:hi,

yes, i did thanks.
Well done
. . . a Beatbox (haha, all beginners go through the same path)
I never wrote a beatbox as a beginner.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!