Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList Sizing

 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created my screen layout which contains a title panel, t=2 JLists with labels and buttons. At the moment I have the 2 JLists and their labels in 2 BoxLayout Panels which I then place into another BoxLayout Panel to stack them vertically. However my problem is that the JLists are stretching to fill the entire center panel. is there anyway i can position this panel in the center with space on either side?
Also is it possible to create more of a dropdown list rather than a JList?
Thanks
 
Eddie Vanda
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use borders with insets:
Border border1 = BorderFactory.createEmptyBorder (5,5,5,5);
Border border2 = BorderFactory.createBevelBorder (BevelBorder.LOWERED);
Border border = BorderFactory.createCompoundBorder (border2, border1);
and then use
setBorder on the Box panel.

Check out JComboBox for a drop down list.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic