提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.common; |
H |
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.FlowLayout; |
|
5 |
import java.awt.event.ActionListener; |
|
6 |
import javax.swing.JButton; |
|
7 |
import javax.swing.JLabel; |
|
8 |
import javax.swing.JOptionPane; |
|
9 |
import javax.swing.JPanel; |
|
10 |
import javax.swing.JPasswordField; |
|
11 |
import javax.swing.JTextField; |
|
12 |
|
|
13 |
import com.iailab.netsdk.lib.ToolKits; |
|
14 |
|
|
15 |
/* |
|
16 |
* 登陆面板 |
|
17 |
*/ |
|
18 |
public class LoginPanel extends JPanel { |
|
19 |
private static final long serialVersionUID = 1L; |
|
20 |
|
|
21 |
//登陆参数 |
|
22 |
private String s_strIp = "172.32.100.88";/*"172.23.12.17";*/ //"192.168.7.61"; |
|
23 |
private Integer s_nPort = new Integer("37777"); |
|
24 |
private String s_strUser = "admin"; |
|
25 |
private String s_strPassword = "admin123"; |
|
26 |
|
|
27 |
public LoginPanel() { |
|
28 |
BorderEx.set(this, Res.string().getLogin(), 2); |
|
29 |
setLayout(new FlowLayout()); |
|
30 |
|
|
31 |
//////////////////////////////// |
|
32 |
loginBtn = new JButton(Res.string().getLogin()); |
|
33 |
logoutBtn = new JButton(Res.string().getLogout()); |
|
34 |
ipLabel = new JLabel(Res.string().getDeviceIp()); |
|
35 |
portLabel = new JLabel(" " + Res.string().getPort()); |
|
36 |
nameLabel = new JLabel(" " + Res.string().getUserName()); |
|
37 |
passwordLabel = new JLabel(" " + Res.string().getPassword()); |
|
38 |
ipTextArea = new JTextField(s_strIp); |
|
39 |
nameTextArea = new JTextField(s_strUser); |
|
40 |
passwordTextArea = new JPasswordField(s_strPassword); |
|
41 |
portTextArea = new JTextField(s_nPort.toString()); |
|
42 |
|
|
43 |
add(ipLabel); |
|
44 |
add(ipTextArea); |
|
45 |
add(portLabel); |
|
46 |
add(portTextArea); |
|
47 |
add(nameLabel); |
|
48 |
add(nameTextArea); |
|
49 |
add(passwordLabel); |
|
50 |
add(passwordTextArea); |
|
51 |
add(loginBtn); |
|
52 |
add(logoutBtn); |
|
53 |
|
|
54 |
ipTextArea.setPreferredSize(new Dimension(90, 20)); |
|
55 |
nameTextArea.setPreferredSize(new Dimension(90, 20)); |
|
56 |
passwordTextArea.setPreferredSize(new Dimension(90, 20)); |
|
57 |
portTextArea.setPreferredSize(new Dimension(90, 20)); |
|
58 |
|
|
59 |
loginBtn.setPreferredSize(new Dimension(80, 20)); |
|
60 |
logoutBtn.setPreferredSize(new Dimension(80, 20)); |
|
61 |
ToolKits.limitTextFieldLength(portTextArea, 6); |
|
62 |
|
|
63 |
logoutBtn.setEnabled(false); |
|
64 |
} |
|
65 |
|
|
66 |
public void addLoginBtnActionListener(ActionListener e) { |
|
67 |
loginBtn.addActionListener(e); |
|
68 |
} |
|
69 |
|
|
70 |
public void addLogoutBtnActionListener(ActionListener e) { |
|
71 |
logoutBtn.addActionListener(e); |
|
72 |
} |
|
73 |
|
|
74 |
public void setButtonEnable(boolean bln) { |
|
75 |
loginBtn.setEnabled(!bln); |
|
76 |
logoutBtn.setEnabled(bln); |
|
77 |
} |
|
78 |
|
|
79 |
public boolean checkLoginText() { |
|
80 |
if(ipTextArea.getText().equals("")) { |
|
81 |
JOptionPane.showMessageDialog(null, Res.string().getInputDeviceIP(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
82 |
return false; |
|
83 |
} |
|
84 |
|
|
85 |
if(portTextArea.getText().equals("")) { |
|
86 |
JOptionPane.showMessageDialog(null, Res.string().getInputDevicePort(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
87 |
return false; |
|
88 |
} |
|
89 |
|
|
90 |
if(nameTextArea.getText().equals("")) { |
|
91 |
JOptionPane.showMessageDialog(null, Res.string().getInputUsername(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
92 |
return false; |
|
93 |
} |
|
94 |
|
|
95 |
if(new String(passwordTextArea.getPassword()).equals("")) { |
|
96 |
JOptionPane.showMessageDialog(null, Res.string().getInputPassword(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
97 |
return false; |
|
98 |
} |
|
99 |
|
|
100 |
return true; |
|
101 |
} |
|
102 |
|
|
103 |
public JLabel nameLabel; |
|
104 |
public JLabel passwordLabel; |
|
105 |
public JLabel ipLabel; |
|
106 |
public JLabel portLabel; |
|
107 |
|
|
108 |
public JTextField ipTextArea; |
|
109 |
public JTextField portTextArea; |
|
110 |
public JTextField nameTextArea; |
|
111 |
public JPasswordField passwordTextArea; |
|
112 |
|
|
113 |
public JButton loginBtn; |
|
114 |
public JButton logoutBtn; |
|
115 |
} |