1
zhanghua
2024-09-26 c775c6953d9759e70f08acbfa8f6d7490aaae3d1
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
package com.netsdk.demo.customize.surfaceEventDemo.frame.basic;
 
import javax.swing.*;
import java.awt.*;
 
/**
 * 登录面板
 *
 * @author 47040
 * @since Created in 2021/5/25 17:09
 */
public class LoginPanel extends JPanel {
 
    private final JButton loginBtn = new JButton("登录");
    private final JButton logoutBtn = new JButton("登出");
 
    private final JTextField ipTextArea = new JTextField("", 15);
    private final JTextField portTextArea = new JTextField("", 8);
    private final JTextField nameTextArea = new JTextField("", 12);
    private final JPasswordField passwordTextArea = new JPasswordField("", 12);
 
    public LoginPanel(String ipAddress, Integer port, String userName, String password) {
        SwingUtil.setBorderEx(this, "登录", 2);
        setLayout(new FlowLayout());
 
        JLabel ipLabel = new JLabel("设备地址");
        ipTextArea.setText(ipAddress);
 
        JLabel portLabel = new JLabel("端口号");
        portTextArea.setText(String.valueOf(port));
 
        JLabel nameLabel = new JLabel("用户名");
        nameTextArea.setText(userName);
 
        JLabel passwordLabel = new JLabel("密码");
        passwordTextArea.setText(password);
 
        add(ipLabel);
        add(ipTextArea);
        add(portLabel);
        add(portTextArea);
        add(nameLabel);
        add(nameTextArea);
        add(passwordLabel);
        add(passwordTextArea);
        add(loginBtn);
        add(logoutBtn);
 
        logoutBtn.setEnabled(false);
    }
 
    public JButton getLoginBtn() {
        return loginBtn;
    }
 
    public JButton getLogoutBtn() {
        return logoutBtn;
    }
 
    public String getIpAddress() {
        return ipTextArea.getText().trim();
    }
 
    public Integer getPort() {
        return Integer.parseInt(portTextArea.getText().trim());
    }
 
    public String getUsername() {
        return nameTextArea.getText().trim();
    }
 
    public String getPassword() {
        return new String(passwordTextArea.getPassword());
    }
 
    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        SwingUtil.SetEnableAllInnerComponent(this, enabled);
    }
}