This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Jlist setListData resizes the Jlist  Component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Jlist setListData resizes the Jlist  Component" Watch "Jlist setListData resizes the Jlist  Component" New topic
Author

Jlist setListData resizes the Jlist Component

Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 88
Hi Guys

when I call
the List resizes to accommodate the size of the arrayList. so if arrayList has 1 element the height of JList is of height 1, if 10 in the list the JList is 10 high.

I just want the list to be fixed height regardless of elements in the list. Component is wrapped in a JScrollPane

Thanks
Alan
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2095
    
    7
See: JList.setVisibleRowCount(int visibleRowCount)
Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 88
Doenst work. I tried this already. If i resize the panel ever so slightly panel then the Jlist repaint to the correct size and fixes at that point
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9995
    
    7

What layout does the container holding the JScrollPane have? Please post your SSCCE code.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 88
I use JGoodies layout. i just solved the issue by using

headerJList.setPrototypeCellValue("Index 1234567890");

The API explains the method.

http://docs.oracle.com/javase/6/docs/api/javax/swing/JList.html

I have 2 other panels where the Jlist is in split panes and I dont have this issue. But i dont want a split pane for this panel as I want a button (with an arrow) between the 2 lists
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jlist setListData resizes the Jlist Component
 
Similar Threads
org.eclipse.swt.widgets.List - how to set visibile row count?
problem selecting JList item
limiting # of JList rows in a JScrollPane
Resizing JTextField
GridBag Layout ( Basic fundas)