Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type JList does not take parameter type <String>

Tags:

java

swing

jlist

When I try to compile some code I keep getting these errors:

CCC.java:21: type javax.swing.JList does not take parameters
JList<String> list;

or:

CCC.java:30: type javax.swing.DefaultListModel does not take parameters
DefaultListModel<String> jobs, DefaultListModel<String> closJ) throws HeadlessException {

I have about 26 of the same error when I try to remove the section i get about 150 lines of errors can anyone help please.

like image 609
user1744348 Avatar asked Dec 18 '25 00:12

user1744348


1 Answers

Generics were added to JList in Java 7. Here's an example from the JList documentation:

String[] data = {"one", "two", "three", "four"};
JList<String> myList = new JList<String>(data);

Make sure you're using Java 7+.

like image 148
Jacob Wallace Avatar answered Dec 20 '25 16:12

Jacob Wallace