Friday, December 23, 2016

NetBeans: warning: [unchecked] unchecked call to setModel(ComboBoxModel) as a member of the raw type

After building a project in NetBeans, the following messages are displayed in the Output area:

warning: [unchecked] unchecked call to setModel(ComboBoxModel<E>) as a member of the raw type JComboBox
        this.typeCombo.setModel(new DefaultComboBoxModel(type));
where E is a type-variable:
      E extends Object declared in class JComboBox

This is because, since Java 7, JComoBox has a generic type for its components.

If you are displaying String in the combo box, you may declare it as below.

       JComboBox<String> = new JComboBox<>();

If you dragged the Combo Box from the Palette to the Design area in NetBeans to build your display, click on the combo box in Design. In general, the Properties will display at the right of the screen. Select the Code tab, and enter <String> in Type Parameters.

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

4 comments:

  1. I did it but warning stands.

    Just see the warning i´m taking below:


    warning: [unchecked] unchecked call to setModel(ComboBoxModel) as a member of the raw type JComboBox
    sexo.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] {"Seleccione o Sexo", "Masculino", "Femenino" }));
    where E is a type-variable:
    E extends Object declared in class JComboBox

    Please Help me...

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Did you define your JComboBox object as JComboBox combo = new JComboBox<String>()?

      Delete
  2. This comment has been removed by the author.

    ReplyDelete