Java多选选择对话框

Java多选选择对话框

本文介绍了Java多选选择对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有下拉菜单的对话框,如下所示:

  Object [] possible = {1 2,3,4}; 
ImageIcon icon = new ImageIcon(images / middle.gif);
int i = Integer.parseInt((String)JOptionPane.showInputDialog(窗格,多少个通道:,重置可见通道,
JOptionPane.PLAIN_MESSAGE,图标,可能性,1)) ;

问题是它只允许您选择一个选项。相反,我想要
用户可以从对话框
中给出的列表中选择多个选项。类似以下内容:

 对象[]可能性= {苹果,橙子,柠檬,葡萄 }; 
ImageIcon icon = new ImageIcon(images / middle.gif);
String s =(String)我在这里放置什么而不是JOptionPane.showInputDialog(); ?

任何人都可以告诉我如何更改这个代码,以便它能够正常地提问? >

很高兴知道我的各种格式选项是什么。我真的很感激任何链接到一些关于这个话题的好文章。我从Google搜索中发现的文章不是很丰富。我可能会使用错误的关键词。

解决方案

也是多种选择的不错选择。


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 likefor users to be able to select multiple options from a list that is given inthe 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.

这篇关于Java多选选择对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 08:28