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

Discussion in 'Java' started by clusardi2k@aol.com, Aug 30, 2012.

  1. Guest

    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,
    , Aug 30, 2012
    #1
    1. Advertising

  2. Jeff Higgins Guest

    Re: How to eliminate warning: unchecked call to additem(E) java asa member of the raw type javax.swing.JComboBox

    On 08/30/2012 11:03 AM, wrote:
    > 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
    Jeff Higgins, Aug 30, 2012
    #2
    1. Advertising

  3. Shyam Guest

    On Thursday, August 30, 2012 8:33:28 PM UTC+5:30, (unknown) wrote:
    > 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!
    Shyam, Aug 30, 2012
    #3
  4. Eric Sosman Guest

    Re: How to eliminate warning: unchecked call to additem(E) java asa member of the raw type javax.swing.JComboBox

    On 8/30/2012 11:03 AM, wrote:
    > 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>(...);

    --
    Eric Sosman
    d
    Eric Sosman, Aug 30, 2012
    #4
  5. Jeff Higgins Guest

    Re: How to eliminate warning: unchecked call to additem(E) java asa member of the raw type javax.swing.JComboBox

    On 08/30/2012 11:03 AM, wrote:
    > 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
    >

    <http://www.greenfoot.org/overview>
    Jeff Higgins, Aug 30, 2012
    #5
  6. Guest

    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,
    , Aug 30, 2012
    #6
  7. Jeff Higgins Guest

    Re: How to eliminate warning: unchecked call to additem(E) java asa member of the raw type javax.swing.JComboBox

    On 08/30/2012 11:57 AM, wrote:
    > 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.

    >
    > Below is the code that I can't change;
    >
    > private void initComponents() {
    > ...
    > jComboBox6 = new javax.swing.JComboBox();
    > }
    >
    > Thank you,
    Jeff Higgins, Aug 30, 2012
    #7
  8. Jeff Higgins Guest

    Re: How to eliminate warning: unchecked call to additem(E) java asa member of the raw type javax.swing.JComboBox

    On 08/30/2012 12:08 PM, Jeff Higgins wrote:
    > On 08/30/2012 11:57 AM, wrote:
    >> 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.


    or Mama.
    >
    >>
    >> Below is the code that I can't change;
    >>
    >> private void initComponents() {
    >> ...
    >> jComboBox6 = new javax.swing.JComboBox();
    >> }
    >>
    >> Thank you,

    >
    Jeff Higgins, Aug 30, 2012
    #8
  9. Eric Sosman Guest

    Re: How to eliminate warning: unchecked call to additem(E) java asa member of the raw type javax.swing.JComboBox

    On 8/30/2012 11:57 AM, wrote:
    > 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, enter <String> in the box, and close.

    > 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.

    --
    Eric Sosman
    d
    Eric Sosman, Aug 30, 2012
    #9
  10. Roedy Green Guest

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

    On Thu, 30 Aug 2012 08:03:27 -0700 (PDT), wrote,
    quoted or indirectly quoted someone who said :

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


    see http://mindprod.com/jgloss/compileerrormessages.html

    see http://mindprod.com/jgloss/generics.html
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    A new scientific truth does not triumph by convincing its opponents and making them see the light,
    but rather because its opponents eventually die, and a new generation grows up that is familiar with it.
    ~ Max Planck 1858-04-23 1947-10-04
    Roedy Green, Sep 2, 2012
    #10
  11. Roedy Green Guest

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

    On Thu, 30 Aug 2012 08:03:27 -0700 (PDT), wrote,
    quoted or indirectly quoted someone who said :

    >ComboBox6.addItem("Big rock");


    see sample code at http://mindprod.com/jgloss/jcombobox.html

    The trick is JComboBox<String>
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    A new scientific truth does not triumph by convincing its opponents and making them see the light,
    but rather because its opponents eventually die, and a new generation grows up that is familiar with it.
    ~ Max Planck 1858-04-23 1947-10-04
    Roedy Green, Sep 4, 2012
    #11
  12. sameer k Guest

    On Thursday, August 30, 2012 9:00:35 PM UTC+5:30, Jeff Higgins wrote:
    > On 08/30/2012 11:03 AM, wrote:
    >
    > > 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


    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.
    sameer k, Sep 6, 2012
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lizard
    Replies:
    0
    Views:
    1,750
    lizard
    Jan 30, 2006
  2. S.T
    Replies:
    2
    Views:
    564
  3. Olumide
    Replies:
    4
    Views:
    527
    James Kanze
    Dec 9, 2007
  4. RVic
    Replies:
    19
    Views:
    1,361
  5. jc_usernet

    Warning unchecked call

    jc_usernet, Jan 22, 2010, in forum: Java
    Replies:
    8
    Views:
    2,335
    busyguy
    Apr 17, 2011
Loading...

Share This Page