JList(E [] listData) constructor from JList has the following syntax.
public JList(E [] listData)
In the following code shows how to use JList.JList(E [] listData) constructor.
/*from ww w .j a v a 2 s . co m*/ import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JScrollPane; public class Main { public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Selection Modes"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList list1 = new JList(labels); JScrollPane sp1 = new JScrollPane(list1); sp1.setColumnHeaderView(new JLabel("List")); frame.add(sp1, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); } }