How to eliminate warning: unchecked call to additem(E) java as amember of the raw type javax.swing.J

C

clusardi2k

Without removing warnings in general, for the below code, how can I remove the below warning.

jComboBox6.addItem("Big rock");

Warning: unchecked call to additem(E) java as a member of the raw type javax.swing.JComboBox

Thank you,
 
J

Jeff Higgins

Without removing warnings in general, for the below code, how can I remove the below warning.

jComboBox6.addItem("Big rock");

Warning: unchecked call to additem(E) java as a member of the raw type javax.swing.JComboBox
generics or annotations
 
S

Shyam

Without removing warnings in general, for the below code, how can I remove the below warning.



jComboBox6.addItem("Big rock");



Warning: unchecked call to additem(E) java as a member of the raw type javax.swing.JComboBox



Thank you,

Just inherit it from the actual one!
 
E

Eric Sosman

Without removing warnings in general, for the below code, how can I remove the below warning.

jComboBox6.addItem("Big rock");

Warning: unchecked call to additem(E) java as a member of the raw type javax.swing.JComboBox

// NO:
JComboBox jComboBox6 = new JComboBox(...);

// YES:
JComboBox<String> jComboBox6 = new JComboBox<String>(...);
 
C

clusardi2k

So, is everyone in agreement that the warning can be prevented by modifying the definition of the jcombobox and and not in this "additem".

I created the jcombobox in NetBeans by dragging it from the swing palette. The definition for it is in code produced by NetBeans and I can't modify.

What do I do.

Below is the code that I can't change;

private void initComponents() {
....
jComboBox6 = new javax.swing.JComboBox();
}

Thank you,
 
J

Jeff Higgins

So, is everyone in agreement that the warning can be prevented by modifying the definition of the jcombobox and and not in this "additem".

I created the jcombobox in NetBeans by dragging it from the swing palette. The definition for it is in code produced by NetBeans and I can't modify.

What do I do.

Forget Netbeans and learn Java.
 
E

Eric Sosman

So, is everyone in agreement that the warning can be prevented by modifying the definition of the jcombobox and and not in this "additem".

I created the jcombobox in NetBeans by dragging it from the swing palette. The definition for it is in code produced by NetBeans and I can't modify.

What do I do.

Below is the code that I can't change;

private void initComponents() {
...
jComboBox6 = new javax.swing.JComboBox();
}

In the NetBeans form editor, select the JComboBox. In the
Properties panel, click the Code tab. Open the Type Parameters
editor said:
Thank you,

It seems to me that you are having more trouble with the
NetBeans form designer and its artifacts than with Java and
Swing. The designer is an intricate beast, with little controls
and menus and twiddly bits festooned all over the landscape, to
the extent that I imagine it might take most of a year's solid
effort to master the complexity. Someone with that mastery
could probably churn out forms faster than someone just typing
Java code -- but the typist has several months' head start while
the other guy is learning how to use the designer.

If you expect to be doing a LOT of form designing, by all
means spend the time to learn the form designer inside and out.
But if you just want a simple form or three, skip the designer:
It will just get in your way (as it seems to be doing now). If
you're having trouble achieving some particular effect you might
create a mock-up in the designer and study the generated code to
get ideas, but I truly think you'll get to a better outcome sooner
by writing the Java code yourself.
 
S

sameer k

generics or annotations

to handle this warning in netbeans right click jcombobox and go to properties and open it,then click code tab and find Type parameters and write String in it. this will fix your problem and want generate this warning. doing this will do same as this code > JComboBox<String> jComboBox6 = new JComboBox<String>(...); and fix it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,696
Members
45,483
Latest member
TedDvb6626

Latest Threads

Top