java - JCheckBox List error? -


i'm coding enigma machine in java, , when program launches, have joptionpane appear 5 jcheckboxes user select rotors use, , in order.

my problem is, added popup, aren't displayed. instead massive readout of 5 checkboxes if called tostring method. have few jlabels on popup display correctly, along ok button @ bottom.

my list initialized 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 this, worked array before, , i've been trying convert don't have call arrays.aslist() on it. i've checked every use of in code, nothing being called tostring or creating errors relating being in list.

how can make display correctly?

you're adding list joptionpane, should add jcheckbox's jpanel , use instead

so, instead of like...

joptionpane.showmessagedialog(null, rotorcheckbox); 

you should use more like...

jpanel panel = new jpanel(); (jcheckbox cb : rotorcheckbox) {     panel.add(cb); } joptionpane.showmessagedialog(null, panel); 

as example


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -