📄 login.java~9~
字号:
package rmichat;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.rmi.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Login extends JFrame {
public Login() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
jLabel1.setText("用户名:");
jLabel1.setBounds(new Rectangle(28, 33, 59, 28));
txtIP.setText("192.168.4.");
txtIP.setBounds(new Rectangle(86, 78, 104, 22));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("聊天室登陆");
jButton1.setBounds(new Rectangle(86, 125, 75, 31));
jButton1.setText("登录");
jButton1.addActionListener(new Login_jButton1_actionAdapter(this));
this.getContentPane().add(jLabel1);
txtName.setBounds(new Rectangle(86, 35, 69, 22));
this.getContentPane().add(jLabel2);
this.getContentPane().add(txtName);
this.getContentPane().add(txtIP);
this.getContentPane().add(jButton1);
jLabel2.setText("IP地址:");
jLabel2.setBounds(new Rectangle(28, 78, 71, 19));
this.setSize(280, 200);
this.setResizable(false);
this.setVisible(true);
}
public static void main(String[] args) {
Login login = new Login();
}
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField txtName = new JTextField();
JTextField txtIP = new JTextField();
JButton jButton1 = new JButton();
public void jButton1_actionPerformed(ActionEvent e) {
try {
Chat server = (Chat) Naming.lookup(
"rmi://localhost/Chat");
if(server.login(txtName.getText())){
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
}
class Login_jButton1_actionAdapter implements ActionListener {
private Login adaptee;
Login_jButton1_actionAdapter(Login adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -