I am using NetBeans IDE 7.1.2. When I compile my application I get the following warning:
warning: [rawtypes] found raw type: JComboBox city = new javax.swing.JComboBox(); missing type arguments for generic class JComboBox where E is a type-variable: E extends Object declared in class JComboBox
So, I guess I have to declare the JComboBox as:
JComboBox<String> city = new JComboBox<String>();
But how do I do this in NetBeans, using the Matisse (Swing GUI Builder)? Please help.
Java 7 introduced generics to the
JComboBox
. One solution to your problem would be to ust Java 6.I'd bet the latest version of Netbeans (7.2) will have a solution for this (although I'm not positive).
Otherwise, if I remember right, you can view the code generated by Netbeans. If so, you may be able to add the generic arguement yourself. It's been many months since I tinkered with Netbeans though...
Also, if the Netbeans allows you to, you can add the
@SupressesWarnings
annotation above theJComboBox
declaration (or even above the class declaration, although that changes it's scope). It would be something like this:There are lots of options, but Netbeans may hold you back from implementing some of them.