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

📄 personneldialog.java

📁 java案例的源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.mwq.frame.explorer;

import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.Field;
import java.util.Vector;

import javax.swing.ButtonGroup;
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.JRadioButton;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import com.mwq.dao.Dao;

public class PersonnelDialog extends JDialog {

	private ButtonGroup buttonGroup = new ButtonGroup();

	private JComboBox dayComboBox;

	private JComboBox monthComboBox;

	private JComboBox yearComboBox;

	private JComboBox typeComboBox;

	private JTextField emailTextField;

	private JTextField handsetTextField;

	private JTextField dutyTextField;

	private JTextField deptTextField;

	private JTextField companyTextField;

	private JTextField nameTextField;

	private JTextField numTextField;

	private final Dao dao = Dao.getInstance();

	/**
	 * Launch the application
	 * 
	 * @param args
	 */
	public static void main(String args[]) {
		try {
			PersonnelDialog dialog = new PersonnelDialog("", "", -1);
			dialog.addWindowListener(new WindowAdapter() {
				public void windowClosing(WindowEvent e) {
					System.exit(0);
				}
			});
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog
	 */
	public PersonnelDialog(String title, String cardName, final int num) {
		super();
		setModal(true);
		getContentPane().setLayout(new GridBagLayout());
		setTitle(title);
		setBounds(100, 100, 500, 375);

		final JLabel numLabel = new JLabel();
		numLabel.setText("编    号:");
		final GridBagConstraints gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridy = 0;
		gridBagConstraints.gridx = 0;
		getContentPane().add(numLabel, gridBagConstraints);

		numTextField = new JTextField();
		numTextField.setHorizontalAlignment(SwingConstants.CENTER);
		numTextField.setEditable(false);
		numTextField.setColumns(13);
		numTextField
				.setText((num < 0 ? dao.sPersonnelIdOfMax() + 1 : num) + "");
		final GridBagConstraints gridBagConstraints_10 = new GridBagConstraints();
		gridBagConstraints_10.anchor = GridBagConstraints.WEST;
		gridBagConstraints_10.gridy = 0;
		gridBagConstraints_10.gridx = 1;
		getContentPane().add(numTextField, gridBagConstraints_10);

		final JLabel typeLabel = new JLabel();
		typeLabel.setText("类    别:");
		final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints();
		gridBagConstraints_1.insets = new Insets(5, 0, 0, 0);
		gridBagConstraints_1.gridy = 1;
		gridBagConstraints_1.gridx = 0;
		getContentPane().add(typeLabel, gridBagConstraints_1);

		typeComboBox = new JComboBox();
		Vector cardV = dao.sTypeByUsed("card");
		for (int i = 0; i < cardV.size(); i++) {
			Vector card = (Vector) cardV.get(i);
			typeComboBox.addItem(card.get(2));
		}
		typeComboBox.setSelectedItem(cardName);
		final GridBagConstraints gridBagConstraints_17 = new GridBagConstraints();
		gridBagConstraints_17.anchor = GridBagConstraints.WEST;
		gridBagConstraints_17.insets = new Insets(5, 0, 0, 0);
		gridBagConstraints_17.gridy = 1;
		gridBagConstraints_17.gridx = 1;
		getContentPane().add(typeComboBox, gridBagConstraints_17);

		final JLabel nameLabel = new JLabel();
		nameLabel.setText("姓    名:");
		final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints();
		gridBagConstraints_2.insets = new Insets(5, 0, 0, 0);
		gridBagConstraints_2.gridy = 2;
		gridBagConstraints_2.gridx = 0;
		getContentPane().add(nameLabel, gridBagConstraints_2);

		nameTextField = new JTextField();
		nameTextField.setName("姓名");
		nameTextField.setColumns(13);
		final GridBagConstraints gridBagConstraints_11 = new GridBagConstraints();
		gridBagConstraints_11.anchor = GridBagConstraints.WEST;
		gridBagConstraints_11.insets = new Insets(5, 0, 0, 0);
		gridBagConstraints_11.gridy = 2;
		gridBagConstraints_11.gridx = 1;
		getContentPane().add(nameTextField, gridBagConstraints_11);

		final JLabel sexLabel = new JLabel();
		sexLabel.setText("性    别:");
		final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints();
		gridBagConstraints_3.insets = new Insets(5, 0, 0, 0);
		gridBagConstraints_3.gridy = 3;
		gridBagConstraints_3.gridx = 0;
		getContentPane().add(sexLabel, gridBagConstraints_3);

		final JPanel sexPanel = new JPanel();
		final FlowLayout flowLayout_1 = new FlowLayout();
		flowLayout_1.setVgap(0);
		flowLayout_1.setHgap(0);
		sexPanel.setLayout(flowLayout_1);
		final GridBagConstraints gridBagConstraints_18 = new GridBagConstraints();
		gridBagConstraints_18.anchor = GridBagConstraints.WEST;
		gridBagConstraints_18.insets = new Insets(5, 0, 0, 0);
		gridBagConstraints_18.gridy = 3;
		gridBagConstraints_18.gridx = 1;
		getContentPane().add(sexPanel, gridBagConstraints_18);

		final JRadioButton manRadioButton = new JRadioButton();
		buttonGroup.add(manRadioButton);
		manRadioButton.setText("男  ");
		sexPanel.add(manRadioButton);

		final JRadioButton womanRadioButton = new JRadioButton();
		buttonGroup.add(womanRadioButton);
		womanRadioButton.setText("女");
		sexPanel.add(womanRadioButton);

		final JLabel birthdayLabel = new JLabel();
		birthdayLabel.setText("出生日期:");
		final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints();
		gridBagConstraints_4.insets = new Insets(5, 0, 0, 0);
		gridBagConstraints_4.gridy = 4;
		gridBagConstraints_4.gridx = 0;
		getContentPane().add(birthdayLabel, gridBagConstraints_4);

		final JPanel birthdayPanel = new JPanel();
		final FlowLayout flowLayout = new FlowLayout();
		flowLayout.setAlignment(FlowLayout.LEFT);
		flowLayout.setVgap(0);
		flowLayout.setHgap(0);
		birthdayPanel.setLayout(flowLayout);
		final GridBagConstraints gridBagConstraints_19 = new GridBagConstraints();
		gridBagConstraints_19.anchor = GridBagConstraints.WEST;
		gridBagConstraints_19.insets = new Insets(5, 0, 0, 0);
		gridBagConstraints_19.gridy = 4;
		gridBagConstraints_19.gridx = 1;
		getContentPane().add(birthdayPanel, gridBagConstraints_19);

		yearComboBox = new JComboBox();
		yearComboBox.addItem("请选择");
		for (int year = 1900; year <= 2020; year++) {
			yearComboBox.addItem(year);
		}
		birthdayPanel.add(yearComboBox);

		final JLabel yearLabel = new JLabel();
		yearLabel.setText("年");
		birthdayPanel.add(yearLabel);

		monthComboBox = new JComboBox();
		monthComboBox.addItem("请选择");
		for (int month = 1; month <= 12; month++) {
			monthComboBox.addItem(month);
		}
		birthdayPanel.add(monthComboBox);

		final JLabel monthLabel = new JLabel();
		monthLabel.setText("月");
		birthdayPanel.add(monthLabel);

⌨️ 快捷键说明

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