📄 roomselectwindow2.java
字号:
/** * Copyright 2004, Martin Jungowski * * This file is part of JHotel. * * JHotel is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * JHotel is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with JHotel; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***/import java.awt.Frame;import java.io.*;import java.util.*;public class RoomSelectWindow2 extends Frame implements Runnable { private javax.swing.JPanel jPanel = null; private ReservationManagement rm; private ShowReservationWindow srw; private int roomtype; private String room; private ArrayList allrooms = new ArrayList(); private String[] settings; private int floors; private javax.swing.JRadioButton jRadioButton = null; private javax.swing.JRadioButton jRadioButton1 = null; private javax.swing.JRadioButton jRadioButton2 = null; private javax.swing.JRadioButton jRadioButton3 = null; private javax.swing.JRadioButton jRadioButton4 = null; private javax.swing.JRadioButton jRadioButton5 = null; private javax.swing.JRadioButton jRadioButton6 = null; private javax.swing.JRadioButton jRadioButton7 = null; Language lang = new Language(); Reservation res; String[] language; int startday; int endday; String selectedRoom; String filename; private javax.swing.JRadioButton jRadioButton8 = null; private javax.swing.JRadioButton jRadioButton9 = null; private javax.swing.JRadioButton jRadioButton10 = null; private javax.swing.JRadioButton jRadioButton11 = null; private javax.swing.JRadioButton jRadioButton12 = null; private javax.swing.JRadioButton jRadioButton13 = null; private javax.swing.JRadioButton jRadioButton14 = null; private javax.swing.JRadioButton jRadioButton15 = null; private javax.swing.JRadioButton jRadioButton16 = null; private javax.swing.JRadioButton jRadioButton17 = null; private javax.swing.JRadioButton jRadioButton18 = null; private javax.swing.JRadioButton jRadioButton19 = null; private javax.swing.JRadioButton jRadioButton20 = null; private javax.swing.JRadioButton jRadioButton21 = null; private javax.swing.JRadioButton jRadioButton22 = null; private javax.swing.JRadioButton jRadioButton23 = null; private javax.swing.JRadioButton jRadioButton24 = null; private javax.swing.JRadioButton jRadioButton25 = null; private javax.swing.JRadioButton jRadioButton26 = null; private javax.swing.JRadioButton jRadioButton27 = null; private javax.swing.JRadioButton jRadioButton28 = null; private javax.swing.JTextField jTextField = null; private javax.swing.JLabel jLabel = null; private javax.swing.JButton jButton = null; private javax.swing.JButton jButton1 = null; ArrayList reservations = new ArrayList(); String[] availableRooms = new String[168]; private javax.swing.JProgressBar jProgressBar = null; /** * This is the default constructor */ public RoomSelectWindow2(ReservationManagement rm, ShowReservationWindow srw, int roomtype, int startday, int endday, ArrayList reservations) { this.rm = rm; this.srw = srw; this.startday = startday; this.endday = endday; this.roomtype = roomtype; this.allrooms = getRooms(roomtype); Options options = new Options(); settings = options.getSettings(); Language lang = new Language(); language = lang.getLanguage(); this.reservations = reservations; this.floors = Integer.parseInt(settings[2]); initialize(); } /*private void loadFile() { try { FileInputStream fis = new FileInputStream("./db/restable.jh"); ObjectInputStream ois = new ObjectInputStream(fis); this.reservations = (ArrayList) ois.readObject(); ois.close(); } catch (ClassNotFoundException cnf) { System.out.println(cnf + " Reservation.makeReservation()"); } catch (IOException io) { System.out.println(io + " Reservation.makeReservation()"); } }*/ private ArrayList getRooms(int roomtype) { ArrayList allrooms; String filename; if (roomtype==1) { filename = "./cfg/single.rms"; } else if (roomtype==2) { filename = "./cfg/double.rms"; } else if (roomtype==3) { filename = "./cfg/triple.rms"; } else if (roomtype==4) { filename = "./cfg/quad.rms"; } else { filename = "./cfg/apartment.rms"; } try { FileInputStream fis = new FileInputStream(filename); ObjectInputStream ois = new ObjectInputStream(fis); allrooms = (ArrayList) ois.readObject(); } catch (IOException io1) { System.out.println(io1 + " in getRooms()"); allrooms = null; } catch (ClassNotFoundException cnf) { System.out.println(cnf + " in getRooms()"); allrooms = null; } return allrooms; } /** * This method initializes this * * @return void */ private void initialize() { this.setLayout(null); this.add(getJRadioButton(), null); this.add(getJRadioButton1(), null); this.add(getJRadioButton2(), null); this.add(getJRadioButton3(), null); this.add(getJRadioButton4(), null); this.add(getJRadioButton5(), null); this.add(getJRadioButton6(), null); this.add(getJRadioButton7(), null); this.add(getJPanel(), null); this.add(getJTextField(), null); this.add(getJLabel(), null); this.add(getJButton(), null); this.add(getJButton1(), null); this.add(getJProgressBar(), null); this.setSize(546, 374); this.setTitle(language[86]); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { dispose(); } }); } /** * This method initializes jPanel * * @return javax.swing.JPanel */ private javax.swing.JPanel getJPanel() { if(jPanel == null) { jPanel = new javax.swing.JPanel(); jPanel.setLayout(null); jPanel.add(getJRadioButton8(), null); jPanel.add(getJRadioButton9(), null); jPanel.add(getJRadioButton10(), null); jPanel.add(getJRadioButton11(), null); jPanel.add(getJRadioButton12(), null); jPanel.add(getJRadioButton13(), null); jPanel.add(getJRadioButton14(), null); jPanel.add(getJRadioButton15(), null); jPanel.add(getJRadioButton16(), null); jPanel.add(getJRadioButton17(), null); jPanel.add(getJRadioButton18(), null); jPanel.add(getJRadioButton19(), null); jPanel.add(getJRadioButton20(), null); jPanel.add(getJRadioButton21(), null); jPanel.add(getJRadioButton22(), null); jPanel.add(getJRadioButton23(), null); jPanel.add(getJRadioButton24(), null); jPanel.add(getJRadioButton25(), null); jPanel.add(getJRadioButton26(), null); jPanel.add(getJRadioButton27(), null); jPanel.add(getJRadioButton28(), null); jPanel.setBounds(44, 137, 446, 196); jPanel.setVisible(true); jPanel.setBackground(java.awt.SystemColor.window); } return jPanel; } /** * This method initializes jRadioButton * * @return javax.swing.JRadioButton */ private javax.swing.JRadioButton getJRadioButton() { if(jRadioButton == null) { jRadioButton = new javax.swing.JRadioButton(); int c = 1; if (c<=floors) { jRadioButton.setVisible(true); } else { jRadioButton.setVisible(false); } jRadioButton.setBounds(22, 37, 108, 18); jRadioButton.setBackground(java.awt.SystemColor.window); jRadioButton.setText("1. " + language[84]); jRadioButton.setEnabled(false); jRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { jRadioButton1.setSelected(false); jRadioButton2.setSelected(false); jRadioButton3.setSelected(false); jRadioButton4.setSelected(false); jRadioButton5.setSelected(false); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false); } }); jRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jPanel.setVisible(true); clearPanel(); checkRoomAvailability(roomtype, 1); } }); } return jRadioButton; } /** * This method initializes jRadioButton1 * * @return javax.swing.JRadioButton */ private javax.swing.JRadioButton getJRadioButton1() { if(jRadioButton1 == null) { jRadioButton1 = new javax.swing.JRadioButton(); int c = 3; if (c<=floors) { jRadioButton1.setVisible(true); } else { jRadioButton1.setVisible(false); } jRadioButton1.setBounds(152, 37, 108, 18); jRadioButton1.setBackground(java.awt.SystemColor.window); jRadioButton1.setText("3. " + language[84]); jRadioButton1.setEnabled(false); jRadioButton1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { jRadioButton.setSelected(false); jRadioButton2.setSelected(false); jRadioButton3.setSelected(false); jRadioButton4.setSelected(false); jRadioButton5.setSelected(false); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false); } }); jRadioButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jPanel.setVisible(true); clearPanel(); checkRoomAvailability(roomtype, 3); } }); } return jRadioButton1; } /** * This method initializes jRadioButton2 * * @return javax.swing.JRadioButton */ private javax.swing.JRadioButton getJRadioButton2() { if(jRadioButton2 == null) { jRadioButton2 = new javax.swing.JRadioButton(); int c = 5; if (c<=floors) { jRadioButton2.setVisible(true); } else { jRadioButton2.setVisible(false); } jRadioButton2.setBounds(282, 37, 108, 18); jRadioButton2.setBackground(java.awt.SystemColor.window); jRadioButton2.setText("5. " + language[84]); jRadioButton2.setEnabled(false); jRadioButton2.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { jRadioButton1.setSelected(false); jRadioButton.setSelected(false); jRadioButton3.setSelected(false); jRadioButton4.setSelected(false); jRadioButton5.setSelected(false); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false); } }); jRadioButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jPanel.setVisible(true); clearPanel(); checkRoomAvailability(roomtype, 5); } }); } return jRadioButton2; } /** * This method initializes jRadioButton3 * * @return javax.swing.JRadioButton */ private javax.swing.JRadioButton getJRadioButton3() { if(jRadioButton3 == null) { jRadioButton3 = new javax.swing.JRadioButton(); int c = 7; if (c<=floors) { jRadioButton3.setVisible(true); } else { jRadioButton3.setVisible(false); } jRadioButton3.setBounds(412, 37, 108, 18); jRadioButton3.setBackground(java.awt.SystemColor.window); jRadioButton3.setText("7. " + language[84]); jRadioButton3.setEnabled(false); jRadioButton3.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { jRadioButton1.setSelected(false); jRadioButton2.setSelected(false); jRadioButton.setSelected(false); jRadioButton4.setSelected(false); jRadioButton5.setSelected(false); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false); } }); jRadioButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jPanel.setVisible(true); clearPanel(); checkRoomAvailability(roomtype, 7); } }); } return jRadioButton3; } /** * This method initializes jRadioButton4 * * @return javax.swing.JRadioButton */ private javax.swing.JRadioButton getJRadioButton4() { if(jRadioButton4 == null) { jRadioButton4 = new javax.swing.JRadioButton(); int c = 2; if (c<=floors) { jRadioButton4.setVisible(true); } else { jRadioButton4.setVisible(false); } jRadioButton4.setBounds(22, 60, 108, 18); jRadioButton4.setBackground(java.awt.SystemColor.window); jRadioButton4.setText("2. " + language[84]); jRadioButton4.setEnabled(false); jRadioButton4.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { jRadioButton1.setSelected(false); jRadioButton2.setSelected(false); jRadioButton3.setSelected(false); jRadioButton.setSelected(false); jRadioButton5.setSelected(false); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false); } }); jRadioButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jPanel.setVisible(true); clearPanel(); checkRoomAvailability(roomtype, 2); } }); } return jRadioButton4; } /** * This method initializes jRadioButton5 * * @return javax.swing.JRadioButton */ private javax.swing.JRadioButton getJRadioButton5() { if(jRadioButton5 == null) { jRadioButton5 = new javax.swing.JRadioButton(); int c = 4; if (c<=floors) { jRadioButton5.setVisible(true); } else { jRadioButton5.setVisible(false); } jRadioButton5.setBounds(152, 60, 108, 18); jRadioButton5.setBackground(java.awt.SystemColor.window); jRadioButton5.setText("4. " + language[84]); jRadioButton5.setEnabled(false); jRadioButton5.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { jRadioButton1.setSelected(false); jRadioButton2.setSelected(false); jRadioButton3.setSelected(false); jRadioButton4.setSelected(false); jRadioButton.setSelected(false); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -