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

📄 userdialog.java

📁 用java开发的QQ管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.zlf.qqserver.usermngpanel;

/**
 * 添加用户的对话框
 */
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FilenameFilter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;

import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.zlf.dao.DaoFactory;
import com.zlf.dao.DeptDao;
import com.zlf.dao.UserDao;
import com.zlf.dao.vo.User;
import com.zlf.qqserver.ServerMain;
import com.zlf.qqserver.utils.QQUtils;

public class UserDialog extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private JLabel userNoLable = new JLabel("用户编号:");

	private JLabel userNameLable = new JLabel("用户姓名:");

	private JLabel userPwdLable = new JLabel("密    码:");

	private JLabel userNickNameLable = new JLabel("用户昵称:");

	private JLabel userSexLable = new JLabel("性    别:");

	private JLabel userAgeLable = new JLabel("年    龄:");

	private JLabel userDeptLable = new JLabel("部    门:");

	private JLabel userPhoneLable = new JLabel("电    话:");

	private JLabel userAddrLable = new JLabel("地    址:");

	private JLabel userRegDateLable = new JLabel("注册时间:");

	private JLabel userLoginLable = new JLabel("登录时间:");

	private JLabel userLoginNumLable = new JLabel("登录次数:");

	private JLabel userOnLineLable = new JLabel("是否在线:");

	private JTextField userNoText = new JTextField(12);

	private JTextField userNameText = new JTextField(8);

	private JPasswordField userPwdText = new JPasswordField(8);

	private JTextField userNickNameText = new JTextField(8);

	private JComboBox userSexCombo = new JComboBox(
			new String[] { "", "男", "女" });

	private JTextField userAgeText = new JTextField(12);

	private JComboBox deptNameCombo;

	private JTextField userPhoneText = new JTextField(8);

	private JTextField userAddrText = new JTextField(20);

	private JTextField userRegDateText = new JTextField(20);

	private JTextField userLoginText = new JTextField(20);

	private JTextField userLoginNumText = new JTextField(20);

	private JTextField userOnLineText = new JTextField(20);

	private JComboBox imageCombo;

	private JButton btnSave = new JButton("保存信息");

	private JButton btnCancel = new JButton("取消操作");

	private DeptDao dao = DaoFactory.newInstance().createDeptDao();
	private UserDao userDao=DaoFactory.newInstance().createUserDao();
	private HashMap h=new HashMap();
	private HashMap userHashMap=new HashMap();
	
	public UserDialog(final int flag, final JDialog dialog, final ServerMain f) {
		// 加载图片
		imageCombo = new JComboBox(this.getNewFaceFiles());
		imageCombo.setRenderer(new IconCombobox());
		// 部门选择下拉框
		h.put("3", "");
		String[] stDeptName = (String[]) dao.selectDept(h).get(0);
		h.clear();
		deptNameCombo = new JComboBox(stDeptName);
		// 布局
		imageCombo.setPreferredSize(new Dimension(50, 55));
		Box userNoBox = Box.createHorizontalBox();
		Box userNameBox = Box.createHorizontalBox();
		Box userPwdBox = Box.createHorizontalBox();
		Box userNickNameBox = Box.createHorizontalBox();
		Box userSexBox = Box.createHorizontalBox();
		Box userAgeBox = Box.createHorizontalBox();
		Box userDeptBox = Box.createHorizontalBox();
		Box userPhoneBox = Box.createHorizontalBox();
		Box userOnLineBox = Box.createHorizontalBox();
		Box userAddrBox = Box.createHorizontalBox();
		Box userRegDateBox = Box.createHorizontalBox();
		Box userLoginBox = Box.createHorizontalBox();
		Box userLoginNumBox = Box.createHorizontalBox();
		Box btnBox = Box.createHorizontalBox();
		Box imageComboBox = Box.createHorizontalBox();

		Box leftBox = Box.createVerticalBox();
		Box rightBox = Box.createVerticalBox();

		userNoBox.add(userNoLable);
		userNoBox.add(userNoText);
		userNameBox.add(userNameLable);
		userNameBox.add(userNameText);

		userPwdBox.add(userPwdLable);
		userPwdBox.add(userPwdText);

		userNickNameBox.add(userNickNameLable);
		userNickNameBox.add(userNickNameText);


		userSexBox.add(userSexLable);
		userSexBox.add(userSexCombo);

		userAgeBox.add(userAgeLable);
		userAgeBox.add(userAgeText);


		userDeptBox.add(userDeptLable);
		userDeptBox.add(deptNameCombo);

		userPhoneBox.add(userPhoneLable);
		userPhoneBox.add(userPhoneText);

		userLoginNumBox.add(userLoginNumLable);
		userLoginNumBox.add(userLoginNumText);

		userOnLineBox.add(userOnLineLable);
		userOnLineBox.add(userOnLineText);

		userAddrBox.add(userAddrLable);
		userAddrBox.add(userAddrText);

		userRegDateBox.add(userRegDateLable);
		userRegDateBox.add(userRegDateText);

		userLoginBox.add(userLoginLable);
		userLoginBox.add(userLoginText);

		imageComboBox.add(Box.createHorizontalStrut(20));
		imageComboBox.add(imageCombo);

		Box userLoginNumAndOnLineBox = Box.createHorizontalBox();
		userLoginNumAndOnLineBox.add(userLoginNumBox);
		userLoginNumAndOnLineBox.add(Box.createHorizontalStrut(10));
		userLoginNumAndOnLineBox.add(userOnLineBox);

		btnBox.add(btnSave);
		btnBox.add(Box.createHorizontalStrut(50));
		btnBox.add(btnCancel);

		leftBox.add(userNoBox);
		leftBox.add(Box.createVerticalStrut(15));
		leftBox.add(userNameBox);
		leftBox.add(Box.createVerticalStrut(15));
		leftBox.add(userPwdBox);
		leftBox.add(Box.createVerticalStrut(15));
		leftBox.add(userSexBox);
		leftBox.add(Box.createVerticalStrut(15));
		leftBox.add(userDeptBox);

		rightBox.add(imageComboBox);
		rightBox.add(Box.createVerticalStrut(15));
		rightBox.add(userNickNameBox);
		rightBox.add(Box.createVerticalStrut(15));
		rightBox.add(userAgeBox);
		rightBox.add(Box.createVerticalStrut(15));
		rightBox.add(userPhoneBox);

		this.setLayout(new BorderLayout());
		Box outBox = Box.createHorizontalBox();
		outBox.add(leftBox);
		outBox.add(Box.createHorizontalStrut(15));
		outBox.add(rightBox);
		// 最外层
		Box outerBox = Box.createVerticalBox();
		outerBox.add(outBox);
		outerBox.add(Box.createVerticalStrut(15));
		outerBox.add(userAddrBox);
		outerBox.add(Box.createVerticalStrut(15));
		outerBox.add(userRegDateBox);
		outerBox.add(Box.createVerticalStrut(15));
		outerBox.add(userLoginBox);
		outerBox.add(Box.createVerticalStrut(15));
		outerBox.add(userLoginNumAndOnLineBox);
		outerBox.add(Box.createVerticalStrut(15));
		outerBox.add(btnBox);
		this.add(outerBox, BorderLayout.CENTER);
		this.add(Box.createVerticalStrut(40), BorderLayout.NORTH);
		this.add(Box.createHorizontalStrut(40), BorderLayout.WEST);
		this.add(Box.createHorizontalStrut(40), BorderLayout.EAST);
		this.add(Box.createVerticalStrut(40), BorderLayout.SOUTH);

		if (flag == 0) {
			// 添加界面
			
			userHashMap.put("4", "");
			String s = (String) userDao.selectUser(userHashMap).get(0);
			userHashMap.clear();
			userNoText.setText(s);
			userNoText.setEnabled(false);
			userPwdText.setText("123456");

⌨️ 快捷键说明

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