【发布时间】:2015-08-22 21:56:26
【问题描述】:
我需要 Java 中的 JOptionPane 方面的帮助。当我单击确定时,一切正常。 :) 但是当我点击 x 时,就像我点击 OK 一样。我该如何解决这个问题。当我点击 x 我想关闭应用程序。这是我的代码。
import javax.swing.JList;
import javax.swing.JOptionPane;
public class Main {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
@SuppressWarnings("rawtypes")
JList choise = new JList(new String[] { "Enter the complaints",
"View complaints" });
JOptionPane.showMessageDialog(null, choise, "Multi-Select Example",
JOptionPane.PLAIN_MESSAGE);
if (choise.getSelectedIndex() == 0) {
new ComplaintsApp();
} else if(choise.getSelectedIndex() == 1 && JOptionPane.OK_OPTION > 0){
new ComplaintsView();
}
}
}
【问题讨论】:
标签: java swing joptionpane