This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250588 - [rawtypes] on generated model initialization
Summary: [rawtypes] on generated model initialization
Status: RESOLVED DUPLICATE of bug 227943
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-20 18:24 UTC by cezariusz
Modified: 2015-09-10 16:27 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cezariusz 2015-02-20 18:24:35 UTC
Create a JPanel. Add a combo box. The following code is generated:

    private javax.swing.JComboBox jComboBox1;
        jComboBox1 = new javax.swing.JComboBox();
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

When trying to compile you get 3 [rawtypes] warnings, which is understandable. So add String type parameter, and the generated code is like this:

    private javax.swing.JComboBox<String> jComboBox1;
        jComboBox1 = new javax.swing.JComboBox<String>();
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

That's better, but you still get one warning:

T:\Work\Sources\NewJPanel.java:32: warning: [rawtypes] found raw type: DefaultComboBoxModel
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
  missing type arguments for generic class DefaultComboBoxModel<E>
  where E is a type-variable:
    E extends Object declared in class DefaultComboBoxModel

The code to init the combo box should use the diamond operator:

    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
Comment 1 Tomas Pavek 2015-09-10 16:27:04 UTC

*** This bug has been marked as a duplicate of bug 227943 ***