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 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.ButtonGroup;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.List;
import java.awt.event.ActionEvent;
import javax.swing.JRadioButton;
public class Registes extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JLabel lblNewLabel;
private boolean isRight;
private boolean isRight1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Registes frame = new Registes();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Registes() {
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);
JLabel label = new JLabel("\u7528\u6237\u540D\uFF1A");
label.setBounds(62, 35, 54, 15);
contentPane.add(label);
JLabel label_1 = new JLabel("\u5BC6\u7801\uFF1A");
label_1.setBounds(62, 102, 54, 15);
contentPane.add(label_1);
textField = new JTextField();
textField.setBounds(156, 32, 161, 21);
contentPane.add(textField);
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setBounds(156, 99, 161, 21);
contentPane.add(textField_1);
textField_1.setColumns(10);
JButton button = new JButton("\u6CE8\u518C");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String username = textField.getText();
String password = textField_1.getText();
String email = textField.getText()+"@softedu.com";
UserService service = new UserServiceImpl();
User user = new User();
if (username=="") {
lblNewLabel.setText("添加失败...");
} else {
user.setUsername(username);
user.setPassword(password);
user.setEmail(email);
if (isRight) {
user.setPrower(0);
} else if (isRight1) {
user.setPrower(1);
}
boolean isRight = service.addInfo(user);
if (isRight) {
// System.out.println("添加成功...");
lblNewLabel.setText("添加成功...");
} else {
lblNewLabel.setText("添加失败...");
}
}
}
});
button.setBounds(62, 193, 93, 23);
contentPane.add(button);
JButton button_1 = new JButton("\u53D6\u6D88");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textField.setText("");
textField_1.setText("");
}
});
button_1.setBounds(266, 193, 93, 23);
contentPane.add(button_1);
JRadioButton radioButton = new JRadioButton("\u666E\u901A\u7528\u6237");
radioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
isRight = radioButton.isSelected();
}
});
radioButton.setBounds(85, 143, 121, 23);
contentPane.add(radioButton);
JRadioButton radioButton_1 = new JRadioButton("\u7BA1\u7406\u5458");
radioButton_1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
isRight1 = radioButton_1.isSelected();
}
});
radioButton_1.setBounds(216, 143, 121, 23);
contentPane.add(radioButton_1);
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(radioButton);
buttonGroup.add(radioButton_1);
lblNewLabel = new JLabel("");
lblNewLabel.setBounds(156, 237, 129, 15);
contentPane.add(lblNewLabel);
JButton button_2 = new JButton("\u9000\u51FA");
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Logins logins = new Logins();
Registes.this.disable();
Registes.this.dispose();
}
});
button_2.setBounds(165, 193, 93, 23);
contentPane.add(button_2);
setVisible(true);
}
}
2019-08-31 Registes extends JFrame
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。