JList is a raw type Warning!

0 The Bullet · March 15, 2015
As of Java 1.7 and later, JList is a raaw type so I keep getting errors and I am unable to run my program. Is there any other way to do this?http://i.imgur.com/4gtc7wC.png

Post a Reply


Oldest  Newest  Rating
0 Branislav Lazic · March 15, 2015
Instead of posting screenshot, post code next time.

What is a "raw type"? JList is a generic class and it expects type argument to be passed upon creation of JList instance.
"Raw type" is when you instantiate JList class without providing type argument.
I.e. if you want to create JList that contains Strings, you would create it like this:

JList<String> list = new JList();

where "String" is a type argument
I recently made tutorial about JList: https://www.youtube.com/watch?v=KOI1WbkKUpQ&list=UUD9USJK11rTGIOHCVWSZNhQ

However, you problem is another thing. You are adding JScrollPane with JList on JList again. Add it to JFrame.

this.add(new JScrollPane(list));

Also, don't set FlowLayout for JFrame in your case.
0 The Bullet · March 16, 2015
I see, thanks for the reply :D
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator