Two Laptop Bag*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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: 89
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: 2204
    
    7
See: JList.setVisibleRowCount(int visibleRowCount)
Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 89
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: 10486
    
    9

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: 89
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
 
 
subject: Jlist setListData resizes the Jlist Component