📄 updateuserinfo.java
字号:
package edu.sccp.chat.frame;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import com.swtdesigner.SwingResourceManager;
import edu.sccp.chat.action.ToServerProcess;
import edu.sccp.chat.jarClass.JarAllege;
import edu.sccp.chat.tools.Check;
public class UpdateUserInfo {
public static JTextField postiontextField;
/**
* @param args
*/
JFrame frame;
JPanel panel;
JLabel label_10;
JLabel label_8;
JLabel label_14;
public static JTextField yearField;
public static JTextField nametextField;
public static JRadioButton men;
String url="";
public static JRadioButton women ;
public static JTextField teltextField;
public static JTextField emailField;
public static JTextArea textArea;
public static JComboBox comboBox;
public static JButton head;
public static JTextField idField;
String headpic="";
JLabel label_11;
private ButtonGroup buttonGroup = new ButtonGroup();
public UpdateUserInfo()
{
JarAllege.bai();
initGUI();
}
private void initGUI()
{
frame=new JFrame("修改用户信息");
frame.setIconImage(SwingResourceManager.getImage(UpdateUserInfo.class, "/edu/sccp/chat/image/icon.png"));
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(final WindowEvent e) {
frame.dispose();
}
public void windowOpened(final WindowEvent e) {
}
});
frame.getContentPane().setLayout(null);
final JLabel label = new JLabel();
label.setText("用户ID:");
label.setBounds(21, 10, 57, 16);
frame.getContentPane().add(label);
idField = new JTextField();//敲回车,根据ID进行查询数据库
idField.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent e)
{
int i=e.getKeyCode();
if(i==KeyEvent.VK_ENTER)
{
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("查找用户信息:"+idField.getText());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
});
idField.setBounds(69, 8, 131, 21);
frame.getContentPane().add(idField);
final JLabel label_1 = new JLabel();
label_1.setText("用户姓名:");
label_1.setBounds(8, 32, 70, 16);
frame.getContentPane().add(label_1);
nametextField = new JTextField();
nametextField.addFocusListener(new FocusAdapter() {
public void focusGained(final FocusEvent e) {
if(nametextField.getText().length()==0)
{
label_10.setText("2-4字符");
}else
label_10.setText("");
}
public void focusLost(final FocusEvent e) {
if(nametextField.getText().length()==0)
{
label_10.setText("不能为空");
}else
label_10.setText("");
}
});
nametextField.setBounds(69, 32, 131, 21);
frame.getContentPane().add(nametextField);
final JLabel label_2 = new JLabel();
label_2.setText("性别:");
label_2.setBounds(21, 61, 41, 16);
frame.getContentPane().add(label_2);
men = new JRadioButton();
buttonGroup.add(men);
men.setText("男");
men.setBounds(62, 59, 45, 25);
frame.getContentPane().add(men);
women = new JRadioButton();
buttonGroup.add(women);
women.setText("女");
women.setBounds(112, 59, 63, 25);
frame.getContentPane().add(women);
final JLabel label_3 = new JLabel();
label_3.setText("所属部门:");
label_3.setBounds(8, 92, 70, 16);
frame.getContentPane().add(label_3);
final JLabel label_4 = new JLabel();
label_4.setText("联系电话:");
label_4.setBounds(8, 148, 65, 16);
frame.getContentPane().add(label_4);
teltextField = new JTextField();
teltextField.addFocusListener(new FocusAdapter() {
public void focusGained(final FocusEvent e) {
if(teltextField.getText().length()==0)
{
label_14.setText("7-12位");
}
}
public void focusLost(final FocusEvent e) {
label_14.setText("");
}
});
teltextField.setBounds(69, 147, 131, 21);
frame.getContentPane().add(teltextField);
final JLabel label_5 = new JLabel();
label_5.setText("E_mail:");
label_5.setBounds(21, 175, 57, 16);
frame.getContentPane().add(label_5);
emailField = new JTextField();
emailField.setBounds(69, 174, 131, 21);
frame.getContentPane().add(emailField);
final JLabel label_6 = new JLabel();
label_6.setText("入职日期:");
label_6.setBounds(8, 209, 65, 16);
frame.getContentPane().add(label_6);
yearField = new JTextField();
yearField.addFocusListener(new FocusAdapter() {
public void focusGained(final FocusEvent e) {
label_11.setText("格式:年-月-日");
}
});
yearField.setBounds(69, 208, 131, 21);
frame.getContentPane().add(yearField);
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(BorderFactory.createTitledBorder("个人备注(30字之内)"));
scrollPane.setBounds(8, 231, 253, 109);
frame.getContentPane().add(scrollPane);
textArea = new JTextArea();
textArea.setLineWrap(true);
scrollPane.setViewportView(textArea);
head = new JButton();
head.setBounds(280, 6, 44, 42);
frame.getContentPane().add(head);
final JButton update = new JButton();
update.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if(nametextField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"姓名不能为空!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}else
{
if(!(Check.checkMsg(nametextField.getText(),2,4,false)))
{
JOptionPane.showMessageDialog(frame,"姓名长度不在范围之内,请保持输入在2-4之内!","警告",JOptionPane.WARNING_MESSAGE,null);
nametextField.setText("");
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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -