我想要一个包含用于用户选择的 JList 的对话框。虽然以下将执行此操作,但我还想要一条消息和一个“取消”按钮。
list = new JList(LstArray1.toArray());
JOptionPane.showMessageDialog(
null, list, "Title", JOptionPane.INFORMATION_MESSAGE);
Run Code Online (Sandbox Code Playgroud)
所以更像这样,但将组合框更改为 JList。
String input = (String) JOptionPane.showInputDialog (null, "Choose from list", "title", JOptionPane.INFORMATION_MESSAGE, null, LstArray2.toArray(), LstArray2.get(0));
Run Code Online (Sandbox Code Playgroud)
我查看了以下内容,但似乎无法找到我需要的内容。 http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html