0

I'd like to define a Swing combobox model as follows:

public class SchemaGroupModel<E> extends AbstractListModel<E> implements ComboBoxModel<E>

but Eclipse raises the error (twice):

The type AbstractListModel is not generic; it cannot be parameterized with arguments <E>

I checked here (raw type definition), here (old JDKs) and here (position of JDK library in the Java Build path). From these replies I guess that the problem should be the version of the JDK or its position in the IDE's libraries. But I doubled checked: I'm using JDK 1.6 and such library comes before Maven dependencies.

Eclipse's screenshot

What am I doing wrong?

Community
  • 1
  • 1
serkelion
  • 73
  • 2
  • 8

1 Answers1

2

This class wasn't generic in Java 6

https://docs.oracle.com/javase/6/docs/api/javax/swing/AbstractListModel.html

public abstract class AbstractListModel
extends Object
implements ListModel, Serializable

you can see that in Java 7 it was made generic.

https://docs.oracle.com/javase/7/docs/api/javax/swing/AbstractListModel.html

public abstract class AbstractListModel<E>
extends Object
implements ListModel<E>, Serializable

however, if you are going to update, I suggest using Java 8 as Java 7 is EOL.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    Thank you very much. I've been misleaded by the (mentioned) answers to similar problems, which suggested to move to version 1.6. Unfortunately I must stay to Java 6 (customer requirements), so I will avoid generics in this case – serkelion Feb 26 '16 at 14:23
  • @serkelion today a fixed a client reported bug which only shows up in Java 8 update 74 but not update 66. A good problem to have I suppose. ;) – Peter Lawrey Feb 26 '16 at 14:30
  • Yes, but this is just the tip of the iceberg. ;) – serkelion Feb 26 '16 at 14:35