Bug 198792 - GUIbuilder generates [unchecked] code for Swing components using javax.swing.ListModel in constructor
GUIbuilder generates [unchecked] code for Swing components using javax.swing...
Status: NEW
Product: guibuilder
Classification: Unclassified
Component: Code
7.0
All All
: P3 with 1 vote (vote)
: 7.2
Assigned To: issues@guibuilder
issues@guibuilder
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-22 12:19 UTC by attila.kelemen
Modified: 2011-10-20 18:48 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description attila.kelemen 2011-05-22 12:19:14 UTC
Since Java7 b143 JComboBox uses generic type for the items stored in it. The GUI builder of NetBeans should be changed to generate code for it that does not issue a warning. E.g.: Allow specifying the type argument or simply use JComboBox<Object>.

Product Version = NetBeans IDE 7.0 (Build 201104080000)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.7.0-ea
Runtime = Java HotSpot(TM) Client VM 21.0-b13
Comment 1 asenk 2011-06-08 13:29:18 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
Comment 2 Jan Stola 2011-10-20 15:07:47 UTC
> 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.
Comment 3 attila.kelemen 2011-10-20 18:48:38 UTC
(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.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo