日期:2014-05-20 浏览次数:21320 次
public class DialogTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String username = JOptionPane.showInputDialog("请输入您的昵称:");
if (username != null && username.length() > 0) {
System.out.println(username);
JOptionPane.showMessageDialog(null, "输入的昵称为:" + username);
} else {
JOptionPane.showMessageDialog(null, "请重新输入您的昵称!");
while(username == null
------解决方案--------------------
username.length() <=0){
username = JOptionPane.showInputDialog("请输入您的昵称:");
}
System.out.println(username);
}
}
}