I'm coding an enigma machine in java, and when the program launches, I have a JOptionPane appear with 5 JCheckBoxes for the user to select which rotors to use, and in which order.
My problem is, they get added to the popup, but they aren't actually displayed. Instead I get a massive readout of all 5 checkboxes as if I called their toString method. I have a few JLabels on the popup that display correctly, along with the OK button at the bottom.
My list is initialized like so:
private final List<JCheckBox> rotorCheckBox = Arrays.asList(new JCheckBox(
"Rotor 1"), new JCheckBox("Rotor 2"), new JCheckBox("Rotor 3"),
new JCheckBox("Rotor 4"), new JCheckBox("Rotor 5"));
I'm not sure why it does this, it worked as an array before, and I've been trying to convert it so I don't have to constantly call Arrays.asList() on it. I've checked every use of it in my code, nothing is being called toString or creating errors relating to it being in a list.
How can I make it display correctly?
You're adding the List to the
JOptionPane, you should add theJCheckBox's to aJPaneland use that insteadSo, instead of something like...
You should use something more like...
as an example