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 and the fly likes Probs with JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
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
 
 
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