This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JList Sizing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList Sizing" Watch "JList Sizing" New topic

JList Sizing

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
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?
Eddie Vanda
Ranch Hand

Joined: Mar 18, 2003
Posts: 281
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.

The nice thing about Standards is that there are so many to choose from!
jQuery in Action, 2nd edition
subject: JList Sizing