我目前正在使用 IntelliJ,当我放置一个案例以在我的菜单中按下 CANCEL 选项时,会出现一个错误,提示“重复标签 '2'”。
import javax.swing.*;
public class Main {
public static void main(String[] args){
int choice=0;
Object menu= "1. Name Constructor\n" +
"2. Pretty Printing of text\n" +
"3. FLAMES\n" +
"4. Your Superhero name!\n" +
"5. return to the main menu\n";
do {
choice = Integer.parseInt(JOptionPane.showInputDialog(null,
"S T R I N G M A N I P U L A T I O N M E N U\n" +
menu, "Menu", 1));
switch (choice) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case JOptionPane.CANCEL_OPTION:
break;
default:
JOptionPane.showMessageDialog(null,"Enter a valid choice.","Error",1);
break;
}
}while(choice!=5);
}
}
潇湘沐
相关分类