package classes;
import javax.swing.*;
public class Input {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成方法存根
try{
String s = JOptionPane.showInputDialog(null,"输入一个字符串","输入",JOptionPane.INFORMATION_MESSAGE);
if(s.equals("abcd") || s.equals("ABCD")){
throw new MyException();
}
while(!s.equals("abcd") || !s.equals("ABCD")){
s = JOptionPane.showInputDialog(null,"输入一个字符串","输入",JOptionPane.INFORMATION_MESSAGE);
if(s.equals("abcd") || s.equals("ABCD")){
throw new MyException();
}
}
}catch(MyException ex){
ex.printStackTrace();
}
}
}
package classes;
public class MyException extends Exception {
public MyException(){
super("ABCD Exception");
}
}