public LoginDialog(GameWin gw,String s,boolean isYouMoShi,Client client){
super(gw, s,isYouMoShi);
this.client=client;
setLayout(null);
setLocation(gw.getDim().width/2-100,200);
loginTf=new JTextField(10);
passwordTf=new JTextField(10);
loginLb=new JLabel("用户名:");
passwordLb=new JLabel("密 码:");
btnLogin=new JButton("登录");
loginTf.setName("登录");
loginLb.setBounds(5, 20, 60, 25);
loginTf.setBounds(50, 20, 100,25);
passwordLb.setBounds(5, 60, 60,25);
passwordTf.setBounds(50, 60, 100,25);
btnLogin.setBounds(60, 100, 70, 30);
btnLogin.addActionListener(this);
loginTf.setBorder (BorderFactory.createLineBorder(Color.black,1));
passwordTf.setBorder (BorderFactory.createLineBorder(Color.black,1));
add(loginLb);
add(loginTf);
add(passwordTf);
add(passwordLb);
add(btnLogin);
setVisible(true);
validate();
}
super(gw, s,isYouMoShi);
this.client=client;
setLayout(null);
getContentPane().setBackground(new Color(12,14,56));
//setBackground(new Color(12,14,56));//会出错!因为分层原因
setLocation(gw.getDim().width/2-100,200);
loginTf=new JTextField(10);
passwordTf=new JTextField(10);
loginLb=new JLabel("用户名:");
passwordLb=new JLabel("密 码:");
btnLogin=new JButton("登录");
loginTf.setName("登录");
loginLb.setBounds(5, 20, 60, 25);
loginTf.setBounds(50, 20, 100,25);
passwordLb.setBounds(5, 60, 60,25);
passwordTf.setBounds(50, 60, 100,25);
btnLogin.setBounds(60, 100, 70, 30);
btnLogin.addActionListener(this);
loginTf.setBorder (BorderFactory.createLineBorder(Color.black,1));
passwordTf.setBorder (BorderFactory.createLineBorder(Color.black,1));
add(loginLb);
add(loginTf);
add(passwordTf);
add(passwordLb);
add(btnLogin);
setVisible(true);
validate();
}