📦 0372hoanghoccode / ko-co

📄 Login_Panel.java · 110 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110package GUI;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import run.loginFrame;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Login_Panel extends JPanel{
	private JButton btn;
	private JLabel lb1;
	private TextField username;
	private JTextField pass;
	private JButton btnClose;
	private loginFrame loginFrameRef; // tham chiếu đến loginFrame

	public void setLoginFrame(loginFrame frame) {
        this.loginFrameRef = frame;
    }
	
	public TextField getUsername() {
		return username;
	}
	public void setUsername(TextField username) {
		this.username = username;
	}
	public JTextField getPass() {
		return pass;
	}
	public void setPass(TextField pass) {
		this.pass = pass;
	}
	public JLabel getLb1() {
		return lb1;
	}
	public void setLb1(JLabel lb1) {
		this.lb1 = lb1;
	}
	public JButton getBtnClose() {
		return btnClose;
	}
	public void setBtnClose(JButton btnClose) {
		this.btnClose = btnClose;
	}
	public Login_Panel() {
		init();
	}
	
	public JButton getBtn() {
		return btn;
	}
	public void setBtn(JButton btn) {
		this.btn = btn;
	}
	public void init() {
		this.setLayout(null);
		this.setVisible(true);
		this.setBounds(600, 0, 400, 550);
		this.setBackground(Color.white);
		
		JLabel label = new JLabel("Đăng Nhập Vào Hệ Thống");
		label.setFont(new Font("Arial",Font.PLAIN,23));
		label.setBounds(69,74,290,30);
		this.add(label);
		
		username = new TextField();
		username.setLabelText("Tên Đăng Nhập");
		username.setBounds(50,180,300,50);
		this.add(username);
		
		pass = new PasswordField();
		((PasswordField)pass).setLabelText("Mật Khẩu");
		pass.setBounds(50,240,300,50);
		this.add(pass);

		btn = new JButton("Đăng Nhập");
        btn.setFont(new Font("Arial",Font.PLAIN,15));
        btn.setForeground(Color.white);
        btn.setBounds(50,340,300,40);
        btn.setBorderPainted(false);
        btn.setFocusPainted(false);
        btn.setBackground(Color.decode("#4CAF12"));
        btn.addMouseListener(new MouseAdapter() {
        public void mouseExited(MouseEvent e) {
           btn.setBackground(Color.decode("#4CAF50"));
        }
        public void mouseEntered(MouseEvent e) {
           btn.setBackground(Color.decode("#4CAF79"));
        }
    });
        btn.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
        loginFrameRef.checkLogin();
        }
    });
    this.add(btn);

	}
}