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 228807 - generic JComboBox's (and other Components?)
Summary: generic JComboBox's (and other Components?)
Status: RESOLVED DUPLICATE of bug 223998
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal with 2 votes (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-21 03:30 UTC by ivan
Modified: 2015-09-10 16:29 UTC (History)
2 users (show)

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 ivan 2013-04-21 03:30:16 UTC
So we switched to Java 7 and I've been busy getting rid of all these [unchecked] warnings.
One area I got a lot of warnings on was JComboBox which is generic.

Getting warnings on matisse-geneared (and therefore readonly) JComboBoxes was a bit
alarming until I discovered the TypeParameters property in the Property editor under Code.
I eventually got it to work but I have a coupla comments ...

1) It turns out the TypeParameters property requires that you enter the parameters
surrounded with <>'s. If you enter just "XXX" you'll end up with a javax.swing.JComboBoxXXX
in the code and it won't compile. Perhaps there should be some validation or automatic
adding of <>'s?

2) The TypeParameters property is used to create two pieces of code. A declaration:
        private javax.swing.JComboBox<ColorValue> foregroundComboBox;
   and an instantiation:
        foregroundComboBox = new javax.swing.JComboBox<ColorValue>();
   The problem is that the instantiation is going to give you the "use diamond operator"
   hint so you won't get to have squeaky-clean code.
Comment 1 Tomas Pavek 2013-10-24 16:10:50 UTC
ad 1) Let's keep bug 237573 for this request.
ad 2) The diamond should be generated automatically when on Java 8 (source level at least 1.8).
Comment 2 Tomas Pavek 2013-10-24 16:56:38 UTC
Correction, diamonds are used since 1.7.
Comment 3 nigjo_iqn 2014-03-31 08:15:14 UTC
I can not confirm diamonds on JDK7 and NetBeans 8.

- Create a new JavaSE Project
- Add a new "JFrame Form"
- Drag a ComboBox from Palette to the Editor

In the source code there are no diamonds used and the "use diamond operator"-hint shows for the creation of the JComboBox and also for the setModel() default implementation.
Comment 4 fscherrer 2015-09-01 00:14:00 UTC
I'm using NetBeans Dev Build 201507200001, and I can still confirm this bug.
The instantiation in the generated initComponents doesn't use diamond operator, which leads to the warning "redundant type arguments in new expression (use diamond operator instead)."
Comment 5 Tomas Pavek 2015-09-10 16:29:45 UTC
"redundant type arguments

223998

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