⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insertuserinfogui.java

📁 企业级的即时通软件。。java语言写的 这是服务端部份。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package edu.sccp.chat.frame;

import java.awt.Color;
import java.awt.ComponentOrientation;
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.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
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.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import com.swtdesigner.SwingResourceManager;

import edu.sccp.chat.bo.DepartmentBO;
import edu.sccp.chat.bo.UserBO;
import edu.sccp.chat.jarClass.JarAllege;
import edu.sccp.chat.tools.Tools;

public class InsertUserInfoGUI {

	private JTextField positionField;
	/**
	 * @param args
	 */
	private JTextArea textArea;
	private JTextField emailField;
	private JTextField delField;
	private JComboBox deptComboBox;
	private ButtonGroup buttonGroup = new ButtonGroup();
	private JComboBox dayComboBox;
	private JComboBox monthComboBox;
	private JComboBox yearComboBox;
	private JPasswordField passwordTwo;
	private JPasswordField passwordField;
	private JTextField nameField;
	public static JTextField idField;
	JLabel label_11;
	JLabel label_12;
	JLabel label_14;
	JLabel label_13;
	JLabel label_16;
	JPanel panel;
	JButton head;
	ImageIcon item=null;
	JFrame frame;
	String headpic="/edu/sccp/chat/image/t2.png";
	String sex;
	boolean flag;
	public InsertUserInfoGUI()
	{
		JarAllege.bai();
		initGUI();
	}
	private void initGUI()
	{
		frame=new JFrame("添加用户");
		frame.setIconImage(SwingResourceManager.getImage(InsertUserInfoGUI.class, "/edu/sccp/chat/image/zhuxiao.png"));
		frame.addWindowListener(new WindowAdapter() {
			public void windowClosing(final WindowEvent e) {
				frame.dispose();
			}
			public void windowOpened(final WindowEvent e) {
				Vector vector=DepartmentBO.selectdept();
				for(int i=0;i<vector.size();i++)
				{
					deptComboBox.addItem(vector.get(i));
				}
			}
		});
		frame.getContentPane().setLayout(null);

		final JLabel label = new JLabel();
		label.setText("ID号:");
		label.setBounds(34, 10, 53, 18);
		frame.getContentPane().add(label);

		idField = new JTextField();
		idField.setBounds(81, 8, 139, 23);
		frame.getContentPane().add(idField);

		final JLabel label_1 = new JLabel();
		label_1.setText("姓名:");
		label_1.setBounds(34, 36, 45, 18);
		frame.getContentPane().add(label_1);

		nameField = new JTextField();
		nameField.addFocusListener(new FocusAdapter() {
			public void focusGained(final FocusEvent e) {
				if(nameField.getText().length()==0)
					{
					label_16.setText("2-4字符");
					}
			}
			public void focusLost(final FocusEvent e) {
				if(nameField.getText().length()==0)
				label_16.setText("不能为空");
				else
					label_16.setText("");
			}
		});
		nameField.setBounds(81, 37, 139, 23);
		frame.getContentPane().add(nameField);

		final JLabel label_2 = new JLabel();
		label_2.setText("密码:");
		label_2.setBounds(34, 65, 47, 18);
		frame.getContentPane().add(label_2);

		passwordField = new JPasswordField();
		passwordField.addFocusListener(new FocusAdapter() {
			public void focusGained(final FocusEvent e) {
				if(passwordField.getText().length()==0)
					{
					label_11.setText("6-10位");
					}
			}
			public void focusLost(final FocusEvent e) {
				if(passwordField.getText().length()==0)
				label_11.setText("不能为空");
				else
					label_11.setText("");
			}
		});
		passwordField.setBounds(81, 63, 139, 23);
		frame.getContentPane().add(passwordField);

		final JLabel label_3 = new JLabel();
		label_3.setText("重复密码:");
		label_3.setBounds(22, 94, 65, 18);
		frame.getContentPane().add(label_3);

		passwordTwo = new JPasswordField();
		passwordTwo.addFocusListener(new FocusAdapter() {
			public void focusGained(final FocusEvent e) {
				if(passwordTwo.getText().length()==0)
					{
					label_12.setText("6-10位");
					}
				else
					label_12.setText("");
			}
			public void focusLost(final FocusEvent e) {
				if(passwordTwo.getText().length()==0)
				label_12.setText("不能为空");
				else
					label_12.setText("");
			}
		});
		passwordTwo.setBounds(81, 92, 139, 23);
		frame.getContentPane().add(passwordTwo);

		final JLabel label_4 = new JLabel();
		label_4.setText("出生日期:");
		label_4.setBounds(22, 123, 65, 18);
		frame.getContentPane().add(label_4);

		yearComboBox = new JComboBox();
		yearComboBox.setBounds(102, 121, 83, 22);
		for(int i=1975;i<=2000;i++)
		{
			yearComboBox.addItem(""+i);
		}
		frame.getContentPane().add(yearComboBox);

		monthComboBox = new JComboBox();
		monthComboBox.setBounds(61, 149, 55, 22);
		for(int i=1;i<=12;i++)
			monthComboBox.addItem(""+i);
		frame.getContentPane().add(monthComboBox);

		dayComboBox = new JComboBox();
		for(int i=1;i<=31;i++)
			dayComboBox.addItem(""+i);
		dayComboBox.setBounds(143, 149, 55, 22);
		frame.getContentPane().add(dayComboBox);

		final JLabel label_5 = new JLabel();
		label_5.setText("年");
		label_5.setBounds(187, 121, 44, 18);
		frame.getContentPane().add(label_5);

		final JLabel label_6 = new JLabel();
		label_6.setText("月");
		label_6.setBounds(122, 151, 27, 18);
		frame.getContentPane().add(label_6);

		final JLabel label_7 = new JLabel();
		label_7.setText("日");
		label_7.setBounds(204, 151, 21, 18);
		frame.getContentPane().add(label_7);

		final JLabel label_8 = new JLabel();
		label_8.setText("性别:");
		label_8.setBounds(34, 180, 49, 18);
		frame.getContentPane().add(label_8);

		final JRadioButton radioButton = new JRadioButton();
		radioButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				sex="男";
			}
		});
		buttonGroup.add(radioButton);
		radioButton.setText("男");
		radioButton.setBounds(80, 176, 51, 21);
		frame.getContentPane().add(radioButton);

		final JRadioButton radioButton_1 = new JRadioButton();
		radioButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				sex="女";
			}
		});
		buttonGroup.add(radioButton_1);
		radioButton_1.setText("女");
		radioButton_1.setBounds(131, 177, 63, 21);
		frame.getContentPane().add(radioButton_1);

		final JLabel label_9 = new JLabel();
		label_9.setText("所在部门:");
		label_9.setBounds(22, 204, 65, 18);
		frame.getContentPane().add(label_9);

		deptComboBox = new JComboBox();
		deptComboBox.setBounds(81, 202, 119, 23);
		frame.getContentPane().add(deptComboBox);

		final JLabel label_10 = new JLabel();
		label_10.setText("联系电话:");
		label_10.setBounds(22, 243, 65, 18);
		frame.getContentPane().add(label_10);

		delField = new JTextField();
		delField.addFocusListener(new FocusAdapter() {
			public void focusGained(final FocusEvent e) {
				if(delField.getText().length()==0)
					{
					label_13.setText("7-12位");
					}
			}
			public void focusLost(final FocusEvent e) {
					label_13.setText("");
			}
	});
		delField.setBounds(81, 241, 139, 23);
		frame.getContentPane().add(delField);

		final JLabel e_mailLabel = new JLabel();
		e_mailLabel.setText("E_maiL:");
		e_mailLabel.setBounds(22, 269, 65, 18);
		frame.getContentPane().add(e_mailLabel);

		emailField = new JTextField();
		emailField.addFocusListener(new FocusAdapter() {
			public void focusLost(final FocusEvent e) {
				if(emailField.getText().equals(""))
					label_14.setText("");
				else if(Tools.includeChar(emailField.getText(), '@') && Tools.includeChar(emailField.getText(), '.'))
					label_14.setText("");
				else
					label_14.setText("Email格式有误");
			}
		});
		emailField.setBounds(81, 267, 139, 23);
		frame.getContentPane().add(emailField);

		final JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBorder(BorderFactory.createTitledBorder("用户备注(30字之内)"));
		scrollPane.setBounds(22, 328, 286, 87);
		frame.getContentPane().add(scrollPane);

		textArea = new JTextArea();
		textArea.addFocusListener(new FocusAdapter() {
			public void focusLost(final FocusEvent e) {
				if(!Tools.checkLength(textArea.getText(), 0, 30))
					JOptionPane.showMessageDialog(frame, "用户备注字符过长(限30字内)", "Warning", JOptionPane.WARNING_MESSAGE);
			
			}
		});
		textArea.setLineWrap(true);
		scrollPane.setViewportView(textArea);

		final JButton commit = new JButton();
		commit.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(!(Tools.checkMsg(idField.getText(),8,10,true)))
		 			{
		 				JOptionPane.showMessageDialog(frame,"用户名输入格式不对,请确认输入的是数字并保持在8-10之内!","警告",JOptionPane.WARNING_MESSAGE,null);
		 				idField.setText("");
		 				return;
		 			}
		 		}
				if(nameField.getText().length()==0)
				{
					JOptionPane.showMessageDialog(frame,"姓名不能为空!","警告",JOptionPane.WARNING_MESSAGE,null);
					return;
				}else
				{
					if(!(Tools.checkMsg(nameField.getText(),2,4,false)))
					{
						JOptionPane.showMessageDialog(frame,"姓名长度不在范围之内,请保持输入在2-4之内!","警告",JOptionPane.WARNING_MESSAGE,null);
						nameField.setText("");
		 				return;
					}
				}
				if(passwordField.getText().length()==0)
				{
				JOptionPane.showMessageDialog(frame,"密码不能为空!","警告",JOptionPane.WARNING_MESSAGE,null);
				return;
				}
			else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -