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.
Summary: | GUIbuilder generates [unchecked] code for Swing components using javax.swing.ListModel in constructor | ||
---|---|---|---|
Product: | guibuilder | Reporter: | attila.kelemen |
Component: | Code | Assignee: | issues@guibuilder <issues> |
Status: | NEW --- | ||
Severity: | normal | CC: | asenk, mmirilovic |
Priority: | P3 | ||
Version: | 7.0 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: |
Description
attila.kelemen
2011-05-22 12:19:14 UTC
In JDK7 javax.swing.ListModel<E> use generic types (as you can see). GUI builder generates not corect JDK7 code for swing components that uses javax.swing.ListModel<E> (or some other classes that implements javax.swing.ListModel<E>).By default the whole generated code is annotated with @SuppressWarnings("unchecked") so no warning code is displayed. But without this annotation you can see this warnig:home/tester/NetBeansProjects/JavaApplication151/src/javaapplication151/NewJFrame.java uses unchecked or unsafe operations. Problem components: jComboBox jList > Allow specifying the type argument or simply use JComboBox<Object>.
You can already specify it: select the component, switch to Code tab in Properties window, modify Type Parameters property (for example, set the value to <Object>).
It remains an open issue if/when GUI Builder should set this property automatically to <Object>. The major problem with this automatic approach is that we are not sure if this form should work in JDK 7 only or if it should work in JDK 6 as well. We don't want to make the class uncompilable in the second case.
This issue can be hardly considered to be a defect because no warning is generated by default (SuppressWarnings annotation must be removed explicitly to get the warning) => I am changing the issue type to enhancement.
(In reply to comment #2) > > Allow specifying the type argument or simply use JComboBox<Object>. > > You can already specify it: select the component, switch to Code tab in > Properties window, modify Type Parameters property (for example, set the value > to <Object>). It seems I have missed this feature, thank you for the info. > > It remains an open issue if/when GUI Builder should set this property > automatically to <Object>. The major problem with this automatic approach is > that we are not sure if this form should work in JDK 7 only or if it should > work in JDK 6 as well. We don't want to make the class uncompilable in the > second case. I believe that if you are using JDK 7, you should not expect files in that project to compile in JDK 6 (or lower). > > This issue can be hardly considered to be a defect because no warning is > generated by default (SuppressWarnings annotation must be removed explicitly to > get the warning) => I am changing the issue type to enhancement. I don't consider this issue a defect but compiling the sources with "-Xlint" will generate warning regardless the "SuppressWarnings" annotation. So although your solution solves the issue setting type paramters to Object (except when there are constraints on the type argument) would be nice. |