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: 4041
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: 3212

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


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18365

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: 4041
> 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
 
Threads others viewed
JList + Vector
How to add elements to Combobox
ComboBox and getSelectedItem !! URGENT
Regarding Combobox Swing
Example 2 Jlists in a JDialog
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture