0

I'm attempting to change the elements of a Combobox that was created through a GUI form.

It generates:

private JComboBox<String> example;

But if I try and do:

example = new JComboBox<>(...);

, nothing occurs. It simply shows the GUI as I set it on the form with no modification.

How am I to modify components while using IntelliJ's GUI form, then?

Orange Receptacle
  • 1,173
  • 3
  • 19
  • 40
  • 1
    The component is initialized by the code generated by the GUI designer, you must not override the initialization. There is `custom create` option available in case you want to initialize the components yourself, otherwise populate the values with `addItem` method. – CrazyCoder Oct 17 '17 at 01:06
  • Is there a way of adding multiple items with one invocation or must I invoke `addItem` multiple times? – Orange Receptacle Oct 17 '17 at 20:12
  • You can either add them in a loop with `addItem` or [add them to a model](https://stackoverflow.com/q/15491211/104891) and set a model to the existing JComboBox. – CrazyCoder Oct 17 '17 at 20:15

0 Answers0