• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Probs with JScrollPane

 
swing it
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I'm trying to add a JList in an JScrollPane as
you can see in the following snippet:
JList jList1 = new JList(new String[]{"gsfdg","gsfdgsfd","gsfdgs","gsfdgf"});
JScrollPane jScrollPane1 = new JScrollPane();
jScrollPane1.add(jList1);
contentPane.add(jScrollPane1, BorderLayout.CENTER);

if the application starts, the listItems are not displayed.
But if I try this code:
JList jList1 = new JList(new String[]{"gsfdg","gsfdgsfd","gsfdgs","gsfdgf"});
contentPane.add(new JScrollPane(jList1), BorderLayout.CENTER);

..everything works fine?
Has anybody an idea, why the first version does not work?
thx in advance
ak
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic