I am writing a Java program and I ran into a problem. I have an ArrayList<JCheckBox>
and I want to show some dialog window with these checkboxes, so I can choose some of them and I want another ArrayList<>
of the selected objects as an outcome after closing that dialog. I think I can get results by adding ActionListener
to those checkboxes, but I don´t know how to pass that ArrayList<JCheckBox>
to the dialog window..
So far I tried something like this:
ArrayList<JCheckBox> al = new ArrayList<JCheckBox>();
for (MyClass mc : sr.getFields().values())
{
JCheckBox box = new JCheckBox(mc.getType());
al.add(box);
}
JOptionPane.showConfirmDialog(null, al);
If I try to print the text in the checkbox, it is ok, but the dialog shows only a long line of some text that does not make any sense..
So, is there a way how to do that?
Thanks in advance..
Aucun commentaire:
Enregistrer un commentaire