I use these lines of code to add a JList to my frame but it doesn't do the job.
DefaultListModel model = new DefaultListModel();
model.addElement("one");
model.addElement("two");
JList list = new JList(model);
this.add(list);
you try this code
DefaultListModel<String> model = new DefaultListModel<>();
model.addElement("one");
model.addElement("two");
JList<String> list = new JList<>(model);
this.add(list);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.