File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes Regarding JList- Combobox Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Regarding JList- Combobox Swing" Watch "Regarding JList- Combobox Swing" New topic
Author

Regarding JList- Combobox Swing

Krunal Naik
Greenhorn

Joined: Mar 14, 2010
Posts: 7
I have Combobox.
In which i will select the value.
after selecting the value I will Show the Jlist.

I have written this code.
but JList doesnt show up.
Vector<String> c = new Vector<String>();
list1= new JList();
list1.setListData(c);
list1.setVisible(true);
list1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
list1.setLayoutOrientation(JList.HORIZONTAL_WRAP);
list1.setVisibleRowCount(-1);

listsc = new JScrollPane(list1);
listsc.setPreferredSize(new Dimension(100,100));
listsc.setAlignmentX(LEFT_ALIGNMENT);

add(listsc,BorderLayout.EAST);

Can you help me why JList doesnt display.
dp = new DefaultListModel();
Michael Dunn
Rancher

Joined: Jun 09, 2003
Posts: 3619
add(listsc,BorderLayout.EAST);

you can't just add a component to a visible container and expect it to appear

you need to
validate() for parents that are awt
revalidate() for parents that are swing

and often, also required is
repaint()
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 2516

Cross post
http://forums.sun.com/thread.jspa?threadID=5432773



luck, db
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 17259

Please BeForthrightWhenCrossPostingToOtherSites.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Krunal Naik
Greenhorn

Joined: Mar 14, 2010
Posts: 7
I deleted post of other forum
Michael Dunn
Rancher

Joined: Jun 09, 2003
Posts: 3619
> I deleted post of other forum

you haven't, so it seems like the final line of reply #3 in the 'other forum' is 100% accurate
 
 
subject: Regarding JList- Combobox Swing
 
MyEclipse, The Clear Choice