• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding JList- Combobox Swing

 
Krunal Naik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5153
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cross post
http://forums.sun.com/thread.jspa?threadID=5432773
 
Rob Spoor
Sheriff
Posts: 20819
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please BeForthrightWhenCrossPostingToOtherSites.
 
Krunal Naik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I deleted post of other forum
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!