wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Probs with JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Probs with JScrollPane " Watch "Probs with JScrollPane " New topic
Author

Probs with JScrollPane

swing it
Greenhorn

Joined: Aug 10, 2001
Posts: 1
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Probs with JScrollPane
 
Similar Threads
Problems with ImageIcon when focus is lost
Box.createGlue() creates nothing
Resizing JPanel and its inner components when JFrame is maximised
GUI designer
wants to focusing on new added list item.. please help