add Component to JPanel

Posted by jouzef19 on Stack Overflow See other posts from Stack Overflow or by jouzef19
Published on 2010-05-22T19:45:12Z Indexed on 2010/05/22 19:50 UTC
Read the original article Hit count: 233

Filed under:
|

Hi , I am using netBeans editor to create desktop application . and i want to add Component without using drag and drop way. I am trying code like this for adding JList to JPanel but nothing showed

JList jl = new JList();
    Vector<String> v= new Vector<String>();
    v.add("one");
    v.add("Two");
    v.add("Three");
    jl.setListData(v);
    JScrollPane js = new JScrollPane(jl);
    js.setLocation(50, 50);
    js.setSize(100, 100);
    js.setVisible(true);
    jPanel1.add(js);

© Stack Overflow or respective owner

Related posts about java

Related posts about jlist