Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList+JScrollPane problem

 
Dorj Galaa
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code is : but JList can't scroll? why?
import javax.swing.*;
public class TestJList
{
public static void main(String args[])
{
JFrame jf1=new JFrame();
jf1.setSize(400,100);
String[] data = {"one", "two", "three", "four","five","six","seven","eight","nine","ten"};
JList jl1=new JList(data);
JScrollPane pane = new JScrollPane(jl1);
jl1.updateUI();
jf1.getContentPane().add(jl1);
jf1.setVisible(true);
}
}
 
Luong Nguyen
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JScrollPane isn't added into the frame.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic