OK i am using eclipse and its GUI editor and i have a string like this:
public static String[] blah = {"Blah", "Blah", "Blah", "Blah"};
and a JComboBox like this:
JComboBox comboBox = new JComboBox(blah);
comboBox.setBounds(10, 56, 312, 37);
contentPane.add(comboBox);
The combobox uses the string above to get its data but when i enter in "blah" to the combobox it has this error...
Type safety: The constructor JComboBox(Object[]) belongs to the raw type JComboBox. References to generic type JComboBox<E> should be parameterized
it works if i run it because it is only a warning but it is annoying because it wont let me enter design mode unless i make it a comment. design mode gives this error...
INVALID SOURCE. No Constructor Binding. --- new JComboBox(locations) is not valid source for component creation, it references not existing constructor.
so i would like to know if there is any other way to overcome this issue
// comboBoxTraceModeSelection = new JComboBox<TraceMode>(TraceMode.values());
comboBoxTraceModeSelection = new JComboBox<TraceMode>();
comboBoxTraceModeSelection.setModel(new DefaultComboBoxModel<TraceMode>
(TraceMode.values()));
This is a workaround for when using enum in a JComboBox (with WindowBuilder on Eclipse 3.7.2 for java 6). Yes, it does seem to be related to Java generics for objects that are a bit out of the ordinary (enum, String, etc). TraceMode is a custom enum. The commented-out line causes the same error as that of the original poster. This is a WindowBuilder issue, not an Eclipse or Java issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With