📄 login.java~87~
字号:
package enterpriseemployeeadministrate;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import com.borland.dx.sql.dataset.*;
import java.sql.*;
public class Login extends JDialog{
JLabel jLabel1 = new JLabel();
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel2 = new JLabel();
JTextField userNameText = new JTextField();
JPasswordField passwordText = new JPasswordField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
Frame1 parentFrame ;
public Login(Frame1 parent) {
super(parent,true);
parentFrame = parent;
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jLabel1.setText("user name");
this.setLocale(java.util.Locale.getDefault());
this.getContentPane().setLayout(xYLayout1);
this.setTitle("login dialog");
jLabel2.setText("password");
userNameText.setText("");
passwordText.setText("");
jButton1.setText("ok");
jButton1.addActionListener(new Login_jButton1_actionAdapter(this));
jButton2.setText("cancel");
jButton2.addActionListener(new Login_jButton2_actionAdapter(this));
//queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "", null, true, Load.ALL));
this.getContentPane().add(jLabel1, new XYConstraints(81, 65, 58, 28));
this.getContentPane().add(userNameText, new XYConstraints(149, 66, 97, 28));
this.getContentPane().add(passwordText, new XYConstraints(149, 130, 97, 28));
this.getContentPane().add(jLabel2, new XYConstraints(80, 128, 58, 28));
this.getContentPane().add(jButton1, new XYConstraints(84, 196, 78, 24));
this.getContentPane().add(jButton2, new XYConstraints(189, 196, 78, 24));
this.setVisible(true);
this.setLocation(200,200);
this.setSize(400,400);
}
public void setUserName(String user){
userNameText.setText(user);
}
public void setPasswordText(String password){
passwordText.setText(password);
}
//设置用户类型为0
//定义查询语句,先定义后使用
int userType;
String user;
String password;
//按下“确定”按钮后的程序
void jButton1_actionPerformed(ActionEvent e) {
int userType;
user = userNameText.getText();
password = passwordText.getText();
LoginControlClass loginControl= new LoginControlClass();
userType= loginControl.getUserType(user, password);
parentFrame.userTypeInfo = userType;
this.dispose() ;
}
//设置获得用户类型的方法,备以後使用
public int getUserType(){ return userType;}
public String getUserName(){
return user;
}
public String getPassword(){
return password;
}
void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class Login_jButton1_actionAdapter implements java.awt.event.ActionListener {
Login adaptee;
Login_jButton1_actionAdapter(Login adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class Login_jButton2_actionAdapter implements java.awt.event.ActionListener {
Login adaptee;
Login_jButton2_actionAdapter(Login adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -