📄 insertinfogui.java
字号:
{
if(!(Check.checkMsg(passwordTwo.getText(), 6, 10, false)))
{
JOptionPane.showMessageDialog(frame,"输入的重复密码不符合长度!","警告",JOptionPane.WARNING_MESSAGE,null);
passwordTwo.setText("");
return;
}
}
if(!passwordField.getText().equals(passwordTwo.getText()))
{
JOptionPane.showMessageDialog(frame,"重复密码和新密码不同!","警告",JOptionPane.WARNING_MESSAGE,null);
passwordField.setText("");
passwordTwo.setText("");
return;
}
if(sex.equals(""))
{
JOptionPane.showMessageDialog(frame,"请选择性别!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
if(postiontextField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"职务不能为空","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}else
{
if((postiontextField.getText().length()>=5))
{
JOptionPane.showMessageDialog(frame,"职务超过5个字符!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
}
if((!(Check.checkMsg(delField.getText(), 7, 12, true)))||delField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"电话输入的不对,请确认是在7-12的数字!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
if((!(Check.includeChar(emailField.getText(),'@')))||emailField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"E_mail输入的格式不正确!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
if(!(Check.checkMsg(textArea.getText(), 0, 30, false)))
{
JOptionPane.showMessageDialog(frame,"备注超过长度!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
String year=(String)yearComboBox.getSelectedItem();
String month=(String)monthComboBox.getSelectedItem();
if(month.length()==1){
month="0"+month;
}
String day=(String)dayComboBox.getSelectedItem();
if(day.length()==1){
day="0"+day;
}
String dept=(String)deptComboBox.getSelectedItem();
String birth=year+month+day;
String name=nameField.getText();
String position=postiontextField.getText();
String remark=textArea.getText();
try {
ToServerProcess.oos.writeObject("插入员工");
Vector user=new Vector();
user.addElement(idField.getText().trim());
user.addElement(name);
user.addElement(passwordField.getText().trim());
user.addElement(position);
user.addElement(dept);
user.addElement(sex);
user.addElement(birth);
user.addElement(delField.getText().trim());
user.addElement(emailField.getText().trim());
user.addElement(headpic);
user.addElement(remark);
ToServerProcess.oos.writeObject(user);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
commit.setText("提交");
commit.setBounds(82, 417, 78, 27);
frame.getContentPane().add(commit);
final JButton butRe = new JButton();
butRe.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
textArea.setText("");
emailField.setText("");
delField.setText("");
passwordTwo.setText("");
passwordField.setText("");
nameField.setText("");
idField.setText("");
}
});
butRe.setText("重置");
butRe.setBounds(187, 417, 77, 27);
frame.getContentPane().add(butRe);
final JButton button_1 = new JButton();
button_1.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
frame.dispose();
}
});
button_1.setText("关闭");
button_1.setBounds(295, 417, 86, 27);
frame.getContentPane().add(button_1);
head = new JButton();
head.setBounds(336, 6, 49, 48);
frame.getContentPane().add(head);
final JButton button_2 = new JButton();
button_2.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
panel.setVisible(true);
}
});
button_2.addMouseListener(new MouseAdapter() {
public void mouseEntered(final MouseEvent e) {
button_2.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/0.gif"));
}
public void mouseExited(final MouseEvent e) {
button_2.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/h7.gif"));
}
});
button_2.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/h7.gif"));
button_2.setBounds(384, 27, 15, 27);
frame.getContentPane().add(button_2);
panel = new JPanel();
panel.setLayout(new GridLayout(0, 1));
panel.setBounds(336, 52, 45, 318);
panel.setVisible(false);
frame.getContentPane().add(panel);
final JButton button_9 = new JButton();
button_9.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_9.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t2.png";
}
});
button_9.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/t2.png"));
panel.add(button_9);
final JButton button_5 = new JButton();
button_5.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_5.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t1.png";
}
});
button_5.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/t1.png"));
panel.add(button_5);
final JButton button_3 = new JButton();
button_3.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_3.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t3.png";
}
});
button_3.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/t3.png"));
panel.add(button_3);
final JButton button_4 = new JButton();
button_4.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/t7.png"));
button_4.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_4.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t7.png";
}
});
panel.add(button_4);
final JButton button_6 = new JButton();
button_6.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/t4.png"));
button_6.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_6.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t4.png";
}
});
panel.add(button_6);
final JButton button_7 = new JButton();
button_7.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/t5.png"));
button_7.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_7.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t5.png";
}
});
panel.add(button_7);
final JButton button_8 = new JButton();
button_8.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/t6.png"));
button_8.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_8.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t6.png";
}
});
panel.add(button_8);
final JButton button_10 = new JButton();
button_10.setIcon(SwingResourceManager.getIcon(InsertInfoGUI.class, "/edu/sccp/chat/image/t8.png"));
button_10.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_10.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t8.png";
}
});
panel.add(button_10);
final JButton button = new JButton();
button.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if(idField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"用户名不能为空!","警告",JOptionPane.WARNING_MESSAGE,null);
idField.setText("");
return;
}
else
{
if(!(Check.checkMsg(idField.getText(),8,10,true)))
{
JOptionPane.showMessageDialog(frame,"用户名输入格式不对,请确认输入的是数字并保持在8-10之内!","警告",JOptionPane.WARNING_MESSAGE,null);
idField.setText("");
return;
}
}
try {
ToServerProcess.oos.writeObject("检测ID");
ToServerProcess.oos.writeObject(idField.getText().trim());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
button.setText("检测ID");
button.setBounds(226, 7, 75, 25);
frame.getContentPane().add(button);
final JLabel label_11 = new JLabel();
label_11.setText("职务:");
label_11.setBounds(45, 244, 57, 16);
frame.getContentPane().add(label_11);
postiontextField = new JTextField();
postiontextField.addFocusListener(new FocusAdapter() {
public void focusGained(final FocusEvent e) {
if(postiontextField.getText().length()==0)
{
label_15.setText("保持在5个字之内");
}else
{
label_15.setText("");
}
}
public void focusLost(final FocusEvent e) {
if(postiontextField.getText().length()==0)
{
label_15.setText("不能为空");
}else
{
label_15.setText("");
}
}
});
postiontextField.setText("员工");
postiontextField.setBounds(83, 239, 137, 21);
frame.getContentPane().add(postiontextField);
label_12 = new JLabel();
label_12.setForeground(new Color(255, 0, 0));
label_12.setBounds(226, 66, 75, 16);
frame.getContentPane().add(label_12);
label_13 = new JLabel();
label_13.setForeground(new Color(255, 0, 0));
label_13.setBounds(229, 95, 72, 16);
frame.getContentPane().add(label_13);
label_14 = new JLabel();
label_14.setForeground(new Color(255, 0, 0));
label_14.setBounds(230, 267, 78, 16);
frame.getContentPane().add(label_14);
label_15 = new JLabel();
label_15.setForeground(new Color(255, 0, 0));
label_15.setBounds(226, 245, 82, 15);
frame.getContentPane().add(label_15);
label_16 = new JLabel();
label_16.setForeground(new Color(255, 0, 0));
label_16.setBounds(226, 39, 60, 15);
frame.getContentPane().add(label_16);
}
public void showGUI()
{
frame.setResizable(false);
frame.setSize(417,478);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
//new InsertInfoGUI().showGUI();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -