Yes/No 在 java 中使用 joptionpane 循环不正确循环
Yes/No loop using joptionpane in java not looping properly
adfdjfjbeuojfbbeoufebfiewbfijahnrl9hgljvrjn4lejugrejura
JOptionPane.showConfirmDialog(null,"choose one", "choose one", JOptionPane.YES_NO_OPTION);
if (result== JOptionPane.NO_OPTION) {
System.exit(0);
}
这是最适合您的可测试示例
public static void main(String[] args) {
int result = JOptionPane.showConfirmDialog(null, "Play again?", "HINT", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION) {
System.out.println("No chosen");
}
if (result == JOptionPane.YES_OPTION) {
System.out.println("Picked YES");
}
}
根据您的需要进行调整
adfdjfjbeuojfbbeoufebfiewbfijahnrl9hgljvrjn4lejugrejura
JOptionPane.showConfirmDialog(null,"choose one", "choose one", JOptionPane.YES_NO_OPTION);
if (result== JOptionPane.NO_OPTION) {
System.exit(0);
}
这是最适合您的可测试示例
public static void main(String[] args) {
int result = JOptionPane.showConfirmDialog(null, "Play again?", "HINT", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION) {
System.out.println("No chosen");
}
if (result == JOptionPane.YES_OPTION) {
System.out.println("Picked YES");
}
}
根据您的需要进行调整