loginview.java
来自「一个企业小型固定资产系统的源代码。发布出来让刚学习java的人研究。」· Java 代码 · 共 105 行
JAVA
105 行
package project;
import javax.swing.*;
import java.awt.*;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
public class LoginView extends JFrame implements ActionListener{
JLabel lblImage = new JLabel();
JLabel lblUserID = new JLabel();
JLabel lblUserPassword = new JLabel();
public JButton jbLogin = new JButton();
public JButton jbReset = new JButton();
public JTextField jtfUserID = new JTextField();
public JPasswordField jtfUserPassword = new JPasswordField();
JPanel jPanel1 = new JPanel();
ImageIcon image1= new ImageIcon("images/10.jpg");
public LoginView(MM mm) {
jPanel1 = (JPanel)this.getContentPane();
jPanel1.setBackground(Color.lightGray);
jPanel1.setLayout(null);
this.setSize(600, 400);
this.setTitle("固定资产管理系统登录");
jPanel1.setLayout(null);
lblUserID.setFont(new java.awt.Font("黑体", Font.PLAIN, 18));
lblUserID.setHorizontalAlignment(SwingConstants.CENTER);
lblUserID.setText("登录名:");
lblUserID.setBounds(new Rectangle(300,200, 83, 29));
this.setLayout(null);
lblUserPassword.setText("密 码:");
lblUserPassword.setBounds(new Rectangle(300,250, 83, 29));
lblUserPassword.setFont(new java.awt.Font("黑体", Font.PLAIN, 18));
lblUserPassword.setHorizontalAlignment(SwingConstants.CENTER);
jbLogin.setBounds(new Rectangle(310, 300, 84, 25));
jbLogin.setFont(new java.awt.Font("黑体", Font.PLAIN, 16));
jbLogin.setText("登录");
jbLogin.setActionCommand("log");
jbLogin.addActionListener(mm);
jbReset.setBounds(new Rectangle(450, 300, 84, 25));
jbReset.setFont(new java.awt.Font("黑体", Font.PLAIN, 16));
jbReset.setText("重置");
jbReset.addActionListener(new resetButton(this));
jtfUserID.setText("zhanghao");
//改
jtfUserID.setHorizontalAlignment(SwingConstants.LEFT);
jtfUserID.setBounds(new Rectangle(400, 200, 137, 21));
jtfUserPassword.setText("abc");
jtfUserPassword.setHorizontalAlignment(SwingConstants.LEFT);
jtfUserPassword.setBounds(new Rectangle(400, 250, 137, 21));
lblImage.setHorizontalAlignment(SwingConstants.RIGHT);
lblImage.setIcon(image1);
lblImage.setBounds(new Rectangle(0,0, 600,400));
this.add(lblUserPassword);
this.add(jbReset);
this.add(jtfUserID);
this.add(jtfUserPassword);
this.add(lblUserID);
this.add(jbLogin);
this.setResizable(false);
this.setVisible(true);
this.add(lblImage);
}
public void resetButton_actionPerformed(ActionEvent e) {
jtfUserID.setText("");
jtfUserPassword.setText("");
}
public void actionPerformed(ActionEvent e) {
}
}
class resetButton implements ActionListener {
private LoginView adaptee;
resetButton(LoginView adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.resetButton_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?