package com.foreknow.view;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.basic.BasicBorders.RadioButtonBorder;
import com.foreknow.model.User;
import com.foreknow.service.UserService;
import com.foreknow.service.impl.UserServiceImpl;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.List;
import java.awt.event.ActionEvent;
import javax.swing.JRadioButton;
public class Logins extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JPasswordField passwordField;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Logins frame = new Logins();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Logins() {
setTitle("Logins");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
//String email = textField.getName()+"@softedu.com";
//System.out.println(textField.getName()+"@softedu.com");
JLabel label = new JLabel("\u7528\u6237\u540D:");
label.setBounds(56, 55, 54, 15);
contentPane.add(label);
JLabel label_1 = new JLabel("\u5BC6\u7801\uFF1A");
label_1.setBounds(56, 126, 54, 15);
contentPane.add(label_1);
textField = new JTextField();
textField.setBounds(156, 52, 162, 21);
contentPane.add(textField);
textField.setColumns(10);
passwordField = new JPasswordField();
passwordField.setBounds(156, 123, 162, 21);
contentPane.add(passwordField);
JButton button = new JButton("\u767B\u5F55");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//调用业务层的方法
UserService service = new UserServiceImpl();
//获取页面中用户填写的用户名与密码
String username = textField.getText();
String password = passwordField.getText();
List<Object> list = service.isValidate(username, password);
if (list.size()>0) {
System.out.println("登陆成功");
User user = (User) list.get(0);
if (user.getPrower()==0) {
MainWindows main = new MainWindows(list);
} else if (user.getPrower()==1) {
MainWindow main = new MainWindow();
}
//创建一个新的页面
//隐藏当前Login的页面
Logins.this.dispose();
} else {
System.out.println("登录失败");
}
}
});
button.setBounds(56, 216, 93, 23);
contentPane.add(button);
JButton button_1 = new JButton("\u6CE8\u518C");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Registes registes = new Registes();
Logins.this.disable();
Logins.this.dispose();
}
});
button_1.setBounds(178, 216, 93, 23);
contentPane.add(button_1);
JButton button_2 = new JButton("\u53D6\u6D88");
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//将文本中的内容取消(清空)
textField.setText("");
passwordField.setText("");
}
});
button_2.setBounds(299, 216, 93, 23);
contentPane.add(button_2);
}
}
2019-08-31 Logins extends JFrame
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...