开发者

Java multiple selection dialog box

I have a dialog box with a drop down menu like this:

Object[] possibilities = {"1", "2", "3", "4"};
ImageIcon icon = new ImageIcon("images/middle.gif");
int i = Integer.parseInt((String)JOptionPane.showInputDialog(pane,"How Many Channels:","Reset Visible Channels",
                JOptionPane.PLAIN_MESSAGE,icon,possibilities,"1"));

The problem is that it only lets you select one option. Instead, I would like for users to be able to select multiple options from a list that is given in the dialog box. Something like the following:

Object[] possibilities = {"apples", "oranges", "lemons", "grapes"};
ImageIcon icon = new ImageIcon("images/middle.gif");
String s = (String)what do i put here instead of JOptionPane.showInputDialog();  ?

Can anyone开发者_如何转开发 show me how to alter this code so that it does what I am asking?

It would be nice to know what some of my various format options are. And I would really appreciate any links to some good articles on the topic. The articles I have found from my google searches are not very informative. I might be using the wrong key words.


JList is also a good alternative for multiple selections.


I would suggest a JTable with 2 columns. The first one is Boolean class based and the second one is text for the boolean.


you probably needed JCheckBox or JRadioButton tutorial shows similair example as you ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜