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

📄 enrolroomframe.java

📁 Java语言编写的员工信息管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import javax.swing.table.*;
import java.util.Vector;
import java.text.*;

public class EnrolRoomFrame extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel guestInfoPanel = null;
	private JLabel nameLabel = null;
	private JTextField nameTextField = null;
	private JLabel genderLabel = null;
	private JRadioButton maleRadioButton = null;
	private JRadioButton femaleRadioButton = null;
	private ButtonGroup groupRadioButton = new ButtonGroup();
	private JLabel certificateIdLabel = null;
	private JTextField certificateIdTextField = null;
	private JLabel nationalityLabel = null;
	private JTextField nationalityTextField = null;
	private JLabel entourageNumLabel = null;
	private JLabel phoneLabel = null;
	private JTextField phoneTextField = null;
	private JLabel addressLabel = null;
	private JTextField adressTextField = null;
	private JLabel postalCodeLabel = null;
	private JTextField postalCodeTextField = null;
	private JLabel arrivalDateLabel = null;
	private JTextField arrivalDateTextField = null;
	private JLabel despositLabel = null;
	private JTextField despositTextField = null;
	private JTextField entourageNumTextField = null;
	private JPanel blankRoomListPanel = null;
	private JPanel choosenRoomListPanel = null;
	private JButton okButton = null;
	private JButton exitButton = null;
	private JLabel blankHintLabel = null;
	private JLabel choosenHintLabel = null;
	
	
	 // 用表格来表示房间列表
	DefaultTableModel blankRoomModel = new DefaultTableModel();

	JTable blankRoomTable = new JTable(blankRoomModel);

	DefaultTableModel choosenRoomModel = new DefaultTableModel();

	JTable choosenRoomTable = new JTable(choosenRoomModel);
	//生成预订类,更新数据库 
	EnrolRoom enrolRoom = new EnrolRoom();
	Vector blankRoomList=new Vector();
	Vector haveChoosenRoomList=new Vector();
	private JButton removeRoomButton = null;

	
	
	/**
	 * This is the default constructor
	 */
	public EnrolRoomFrame() {
		
		initialize();			
		//从ReserveRoom类型对象获取房间状态信息   
		//设置从ReserveRoom类对象获取的信息: 房间状态信息
		//刚开始,reserveRoom.reserveInfo.choosenRoomList放的是空房间信息表
		Room room=new Room();
		blankRoomList=new Vector();
		blankRoomList = enrolRoom.getBlankRoomList();
		//将空房间信息表放到那个Table中
		for(int i=0;i<blankRoomList.size();i++)
		{
			room=(Room)blankRoomList.get(i);			
			blankRoomModel.addRow(new Object[]{ room.id.toString().trim(),
							room.roomClass.toString().trim(),
							Integer.toString(room.fee)					
			});	
		}
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(404, 423);
		this.setName("ReserveRoomFrame");
		this.setContentPane(getJContentPane());
		this.setTitle("预定房间");
		groupRadioButton.add(maleRadioButton);
		groupRadioButton.add(femaleRadioButton); 
		
		
		
		JScrollPane blanktablescrollpane = new JScrollPane(blankRoomTable);
		blankRoomListPanel.add(blanktablescrollpane);
		blankRoomListPanel.add(blanktablescrollpane);
		JScrollPane choosentablescrollpane = new JScrollPane(choosenRoomTable);
		choosenRoomListPanel.add(choosentablescrollpane);
		choosenRoomListPanel.add(choosentablescrollpane);
		// ///////////////////////////////////////////
		blankRoomModel.addColumn("房号");
		blankRoomModel.addColumn("类别");
		blankRoomModel.addColumn("价格");
		blankRoomTable.setPreferredScrollableViewportSize(new Dimension(170,
				150));
		blankRoomTable.setBackground(new Color(255, 255, 210));
		blankRoomTable.setRowHeight(20);
		blankRoomTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

		// ////////////////////////////////////////// /
		choosenRoomModel.addColumn("房号");
		choosenRoomModel.addColumn("类别");
		choosenRoomTable.setPreferredScrollableViewportSize(new Dimension(110,
				150));
		choosenRoomTable.setBackground(new Color(255, 255, 210));
		choosenRoomTable.setRowHeight(20);
		choosenRoomTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		// ////////////////////////////////////////////////	
		//表鼠标双击事件处理		
	    blankRoomTable.addMouseListener(new java.awt.event.MouseAdapter(){
	    	public void mousePressed(MouseEvent e) {
	        	if(e.getSource()==blankRoomTable)
	  	 		{  
	  	 			if(e.getClickCount()==2)		//鼠标双击
	  	 			{
	  	 				System.out.println("鼠标双击事件处理");
	  	 				addRoomToChoosenList_doubleClick(e);
	  	 				blankRoomTable.setFocusable(false);
	  	      		}
	  	      	
	  	 		}
	      	}
	    });	
	    
		// 将当前日期记录成字符串格式,以便存到数据库,到时候,又可以转化回来成为日期对象
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date d = new Date();
		String s = sdf.format(d) + "";
		this.arrivalDateTextField.setText(s);

	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getGuestInfoPanel(), null);
			jContentPane.add(getBlankRoomListPanel(), null);
			jContentPane.add(getChoosenRoomListPanel(), null);
			jContentPane.add(getOkButton(), null);
			jContentPane.add(getExitButton(), null);
			jContentPane.add(getRemoveRoomButton(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes guestInfoPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getGuestInfoPanel() {
		if (guestInfoPanel == null) {
			despositLabel = new JLabel();
			despositLabel.setBounds(new java.awt.Rectangle(23,152,26,18));
			despositLabel.setText("押金");
			arrivalDateLabel = new JLabel();
			arrivalDateLabel.setBounds(new java.awt.Rectangle(175,121,57,18));
			arrivalDateLabel.setText("到达日期");
			postalCodeLabel = new JLabel();
			postalCodeLabel.setBounds(new java.awt.Rectangle(23,118,26,18));
			postalCodeLabel.setText("邮编");
			addressLabel = new JLabel();
			addressLabel.setBounds(new java.awt.Rectangle(194,84,38,18));
			addressLabel.setText("地址");
			phoneLabel = new JLabel();
			phoneLabel.setBounds(new java.awt.Rectangle(23,81,38,18));
			phoneLabel.setText("电话");
			entourageNumLabel = new JLabel();
			entourageNumLabel.setBounds(new java.awt.Rectangle(206,154,26,18));
			entourageNumLabel.setText("人数");
			nationalityLabel = new JLabel();
			nationalityLabel.setBounds(new java.awt.Rectangle(197,50,35,18));
			nationalityLabel.setText("国籍");
			certificateIdLabel = new JLabel();
			certificateIdLabel.setBounds(new java.awt.Rectangle(23,48,54,18));
			certificateIdLabel.setText("证件号码");
			genderLabel = new JLabel();
			genderLabel.setBounds(new java.awt.Rectangle(197,14,35,18));
			genderLabel.setText("性别");
			nameLabel = new JLabel();
			nameLabel.setText("姓名");
			nameLabel.setBounds(new java.awt.Rectangle(23,16,30,18));
			guestInfoPanel = new JPanel();
			guestInfoPanel.setLayout(null);
			guestInfoPanel.setBounds(new java.awt.Rectangle(11,8,372,189));
			guestInfoPanel.setBackground(new java.awt.Color(204,204,204));
			guestInfoPanel.add(nameLabel, null);
			guestInfoPanel.add(getNameTextField(), null);
			guestInfoPanel.add(genderLabel, null);
			guestInfoPanel.add(getMaleRadioButton(), null);
			guestInfoPanel.add(getFemaleRadioButton(), null);
			guestInfoPanel.add(certificateIdLabel, null);
			guestInfoPanel.add(getCertificateIdTextField(), null);
			guestInfoPanel.add(nationalityLabel, null);
			guestInfoPanel.add(getNationalityTextField(), null);
			guestInfoPanel.add(entourageNumLabel, null);
			guestInfoPanel.add(phoneLabel, null);
			guestInfoPanel.add(getPhoneTextField(), null);
			guestInfoPanel.add(addressLabel, null);
			guestInfoPanel.add(getAdressTextField(), null);
			guestInfoPanel.add(postalCodeLabel, null);
			guestInfoPanel.add(getPostalCodeTextField(), null);
			guestInfoPanel.add(arrivalDateLabel, null);
			guestInfoPanel.add(getArrivalDateTextField(), null);
			guestInfoPanel.add(despositLabel, null);
			guestInfoPanel.add(getDespositTextField(), null);
			guestInfoPanel.add(getEntourageNumTextField(), null);
			
		}
		return guestInfoPanel;
	}

	/**
	 * This method initializes nameTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getNameTextField() {
		if (nameTextField == null) {
			nameTextField = new JTextField();
			nameTextField.setBounds(new java.awt.Rectangle(83,16,61,22));
		}
		return nameTextField;
	}

	/**
	 * This method initializes jRadioButton	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getMaleRadioButton() {
		if (maleRadioButton == null) {
			maleRadioButton = new JRadioButton();
			maleRadioButton.setBounds(new java.awt.Rectangle(255,14,40,21));
			maleRadioButton.setText("男");
		}
		return maleRadioButton;
	}

	/**
	 * This method initializes jRadioButton	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getFemaleRadioButton() {
		if (femaleRadioButton == null) {
			femaleRadioButton = new JRadioButton();
			femaleRadioButton.setBounds(new java.awt.Rectangle(298,14,40,21));
			femaleRadioButton.setText("女");
		}
		return femaleRadioButton;
	}

	/**
	 * This method initializes certificateIdTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getCertificateIdTextField() {
		if (certificateIdTextField == null) {
			certificateIdTextField = new JTextField();
			certificateIdTextField.setBounds(new java.awt.Rectangle(88,49,56,22));
		}
		return certificateIdTextField;
	}

⌨️ 快捷键说明

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