JAVA初学,求指导。
程序代码:import java.awt.Toolkit;
import javax.swing.JFrame;
public class fivechess extends JFrame{
public fivechess(){
this.setSize(500,500);
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((width-500)/2, (height-500)/2);
this.setVisible(true);
}
}
程序代码:import javax.swing.JOptionPane;
public class test {
public static void main(String[] args)
{
fivechess fc=new fivechess();
String username;
do{
username=JOptionPane.showInputDialog("请输入你的用户名:");
if(username!=null || username!="")
{
System.out.println(username);
JOptionPane.showMessageDialog(fc,"你的名字是"+ username);
}
else
{
JOptionPane.showMessageDialog(fc,"请重新输入你的名字");
}
}
while (username==null || username=="");
}
}
其中fc调用firechess类。
在eclipes中调试,直接确定,并不提示出错。只是不输入用户名时,程序一样执行。请找出bug。








