Expand|Select|Wrap|Line Numbers
- import java.io.*;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- import java.text.*;
- public class LenzHotel extends JFrame implements ActionListener
- {
- DataInputStream output;
- DataInputStream input;
- //contruct components
- JTextArea roomDisplay1 = new JTextArea();
- JTextArea roomDisplay2 = new JTextArea();
- JTextArea roomDisplay3 = new JTextArea();
- JTextArea roomDisplay4 = new JTextArea();
- JTextArea roomDisplay5 = new JTextArea();
- JTextArea roomDisplay6 = new JTextArea();
- JTextArea roomDisplay7 = new JTextArea();
- JTextArea roomDisplay8 = new JTextArea();
- JTextArea roomDisplay9 = new JTextArea();
- JTextArea roomDisplay10 = new JTextArea();
- JTextArea roomDisplay11 = new JTextArea();
- JTextArea roomDisplay12 = new JTextArea();
- JTextArea roomDisplay13 = new JTextArea();
- JTextArea roomDisplay14 = new JTextArea();
- JTextArea roomDisplay15 = new JTextArea();
- JTextArea roomDisplay16 = new JTextArea();
- JTextArea roomDisplay17 = new JTextArea();
- JTextArea roomDisplay18 = new JTextArea();
- JTextArea roomDisplay19 = new JTextArea();
- JTextArea roomDisplay20 = new JTextArea();
- JComboBox choice = new JComboBox();
- JLabel name = new JLabel("Name");
- JTextField nameField = new JTextField(15);
- JLabel phone = new JLabel("Phone Number");
- JTextField phoneField = new JTextField(15);
- JLabel vehicle = new JLabel("Vehicle Registration Number");
- JTextField vehicleField = new JTextField(15);
- JLabel address = new JLabel("Customers address");
- JTextField addressField = new JTextField(15);
- JLabel checkin = new JLabel("Check in time and date");
- JTextField checkinField = new JTextField(15);
- JLabel business = new JLabel("Business or Overnight");
- JTextField businessField = new JTextField(15);
- JLabel tariff = new JLabel("Tariff");
- JTextField tariffField = new JTextField(15);
- JLabel deposit = new JLabel("Deposit");
- JTextField depositField = new JTextField(15);
- JLabel checkout = new JLabel("Check out Time and Date");
- JTextField checkoutField = new JTextField(15);
- JLabel choiceLabel = new JLabel("Clear which Field");
- JComboBox smoking = new JComboBox();
- JLabel bookLabel = new JLabel("Book which room");
- JComboBox book = new JComboBox();
- JButton bookButton = new JButton("Book room");
- public LenzHotel()
- {
- super("Lenasia Hotel");
- }
- public Container createContentPane()
- {
- JPanel bottomPanel = new JPanel();
- bottomPanel.add(bookLabel);
- bottomPanel.add(book);
- bottomPanel.add(choice);
- book.addItem("1");
- book.setActionCommand("one");
- book.addItem("2");
- book.setActionCommand("two");
- book.addActionListener(this);
- book.addItem("3");
- book.setActionCommand("three");
- book.addActionListener(this);
- book.addItem("4");
- book.setActionCommand("four");
- book.addActionListener(this);
- book.addItem("5");
- book.setActionCommand("five");
- book.addActionListener(this);
- book.addItem("6");
- book.setActionCommand("six");
- book.addActionListener(this);
- book.addItem("7");
- book.setActionCommand("seven");
- book.addActionListener(this);
- book.addItem("8");
- book.setActionCommand("eight");
- book.addActionListener(this);
- book.addItem("9");
- book.setActionCommand("nine");
- book.addActionListener(this);
- book.addItem("10");
- book.setActionCommand("ten");
- book.addActionListener(this);
- book.addItem("11");
- book.setActionCommand("eleven");
- book.addActionListener(this);
- book.addItem("12");
- book.setActionCommand("twelve");
- book.addActionListener(this);
- book.addItem("13");
- book.setActionCommand("thirteen");
- book.addActionListener(this);
- book.addItem("14");
- book.setActionCommand("fourteen");
- book.addActionListener(this);
- book.addItem("15");
- book.setActionCommand("fifteen");
- book.addActionListener(this);
- book.addItem("sixteen");
- book.setActionCommand("16");
- book.addActionListener(this);
- book.addItem("seventeen");
- book.setActionCommand("17");
- book.addActionListener(this);
- book.addItem("eighteen");
- book.setActionCommand("18");
- book.addActionListener(this);
- book.addItem("nineteen");
- book.setActionCommand("19");
- book.addActionListener(this);
- book.addItem("20");
- book.setActionCommand("twenty");
- book.addActionListener(this);
- bottomPanel.add(bookButton);
- bookButton.addActionListener(this);
- bottomPanel.add(choiceLabel);
- bottomPanel.add(choice);
- choice.addItem("1");
- choice.setActionCommand("1");
- choice.addActionListener(this);
- choice.addItem("2");
- choice.setActionCommand("2");
- choice.addActionListener(this);
- choice.addItem("3");
- choice.setActionCommand("3");
- choice.addActionListener(this);
- choice.addItem("4");
- choice.setActionCommand("4");
- choice.addActionListener(this);
- choice.addItem("5");
- choice.setActionCommand("5");
- choice.addActionListener(this);
- choice.addItem("6");
- choice.setActionCommand("6");
- choice.addActionListener(this);
- choice.addItem("7");
- choice.setActionCommand("7");
- choice.addActionListener(this);
- choice.addItem("8");
- choice.setActionCommand("8");
- choice.addActionListener(this);
- choice.addItem("9");
- choice.setActionCommand("9");
- choice.addActionListener(this);
- choice.addItem("10");
- choice.setActionCommand("10");
- choice.addActionListener(this);
- choice.addItem("11");
- choice.setActionCommand("11");
- choice.addActionListener(this);
- choice.addItem("12");
- choice.setActionCommand("12");
- choice.addActionListener(this);
- choice.addItem("13");
- choice.setActionCommand("13");
- choice.addActionListener(this);
- choice.addItem("14");
- choice.setActionCommand("14");
- choice.addActionListener(this);
- choice.addItem("15");
- choice.setActionCommand("15");
- choice.addActionListener(this);
- choice.addItem("16");
- choice.setActionCommand("16");
- choice.addActionListener(this);
- choice.addItem("17");
- choice.setActionCommand("17");
- choice.addActionListener(this);
- choice.addItem("18");
- choice.setActionCommand("18");
- choice.addActionListener(this);
- choice.addItem("19");
- choice.setActionCommand("19");
- choice.addActionListener(this);
- choice.addItem("20");
- choice.setActionCommand("20");
- choice.addActionListener(this);
- JPanel northPanel = new JPanel();
- northPanel.setLayout(new GridLayout(5,4,10,10));
- northPanel.add(roomDisplay1);
- roomDisplay1.setColumns(5);
- roomDisplay1.setRows(5);
- roomDisplay1.setLineWrap(true);
- roomDisplay1.setBackground(Color.green);
- roomDisplay1.setText("Room 1");
- roomDisplay1.setEditable(false);
- JScrollPane scrollPane1 = new JScrollPane(roomDisplay1);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane1);
- northPanel.add(roomDisplay2);
- roomDisplay2.setColumns(5);
- roomDisplay2.setRows(5);
- roomDisplay2.setLineWrap(true);
- roomDisplay2.setText("Room 2");
- roomDisplay2.setEditable(false);
- roomDisplay2.setBackground(Color.green);
- JScrollPane scrollPane2 = new JScrollPane(roomDisplay2);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane2);
- northPanel.add(roomDisplay3);
- roomDisplay3.setColumns(5);
- roomDisplay3.setRows(5);
- roomDisplay3.setLineWrap(true);
- roomDisplay3.setText("Room 3");
- roomDisplay3.setEditable(false);
- roomDisplay3.setBackground(Color.green);
- JScrollPane scrollPane3 = new JScrollPane(roomDisplay3);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane3);
- northPanel.add(roomDisplay4);
- roomDisplay4.setColumns(5);
- roomDisplay4.setRows(5);
- roomDisplay4.setLineWrap(true);
- roomDisplay4.setText("Room 4");
- roomDisplay4.setEditable(false);
- roomDisplay4.setBackground(Color.green);
- JScrollPane scrollPane4 = new JScrollPane(roomDisplay4);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane4);
- northPanel.add(roomDisplay5);
- roomDisplay5.setColumns(5);
- roomDisplay5.setRows(5);
- roomDisplay5.setLineWrap(true);
- roomDisplay5.setText("Room 5");
- roomDisplay5.setEditable(false);
- roomDisplay5.setBackground(Color.green);
- JScrollPane scrollPane5 = new JScrollPane(roomDisplay5);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane5);
- northPanel.add(roomDisplay6);
- roomDisplay6.setColumns(5);
- roomDisplay6.setRows(5);
- roomDisplay6.setLineWrap(true);
- roomDisplay6.setText("Room 6");
- roomDisplay6.setEditable(false);
- roomDisplay6.setBackground(Color.green);
- JScrollPane scrollPane6 = new JScrollPane(roomDisplay6);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane6);
- northPanel.add(roomDisplay7);
- roomDisplay7.setColumns(5);
- roomDisplay7.setRows(5);
- roomDisplay7.setLineWrap(true);
- roomDisplay7.setText("Room 7");
- roomDisplay7.setEditable(false);
- roomDisplay7.setBackground(Color.green);
- JScrollPane scrollPane7 = new JScrollPane(roomDisplay7);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane7);
- northPanel.add(roomDisplay8);
- roomDisplay8.setText("Room 8");
- roomDisplay8.setColumns(5);
- roomDisplay8.setRows(5);
- roomDisplay8.setLineWrap(true);
- roomDisplay8.setEditable(false);
- roomDisplay8.setBackground(Color.green);
- JScrollPane scrollPane8 = new JScrollPane(roomDisplay8);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane8);
- northPanel.add(roomDisplay9);
- roomDisplay9.setColumns(5);
- roomDisplay9.setRows(5);
- roomDisplay9.setLineWrap(true);
- roomDisplay9.setText("Room 9");
- roomDisplay9.setEditable(false);
- roomDisplay9.setBackground(Color.green);
- JScrollPane scrollPane9 = new JScrollPane(roomDisplay9);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane9);
- northPanel.add(roomDisplay10);
- roomDisplay10.setColumns(5);
- roomDisplay10.setRows(5);
- roomDisplay10.setLineWrap(true);
- roomDisplay10.setText("Room 10");
- roomDisplay10.setEditable(false);
- roomDisplay10.setBackground(Color.green);
- JScrollPane scrollPane10 = new JScrollPane(roomDisplay10);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane10);
- northPanel.add(roomDisplay11);
- roomDisplay11.setColumns(5);
- roomDisplay11.setRows(5);
- roomDisplay11.setLineWrap(true);
- roomDisplay11.setText("Room 11");
- roomDisplay11.setEditable(false);
- roomDisplay11.setBackground(Color.green);
- JScrollPane scrollPane11 = new JScrollPane(roomDisplay11);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane11);
- northPanel.add(roomDisplay12);
- roomDisplay12.setColumns(5);
- roomDisplay12.setRows(5);
- roomDisplay12.setLineWrap(true);
- roomDisplay12.setText("Room 12");
- roomDisplay12.setEditable(false);
- roomDisplay12.setBackground(Color.green);
- JScrollPane scrollPane12 = new JScrollPane(roomDisplay12);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane12);
- northPanel.add(roomDisplay13);
- roomDisplay13.setColumns(5);
- roomDisplay13.setRows(5);
- roomDisplay13.setLineWrap(true);
- roomDisplay13.setText("Room 13");
- roomDisplay13.setEditable(false);
- roomDisplay13.setBackground(Color.green);
- JScrollPane scrollPane13 = new JScrollPane(roomDisplay13);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane13);
- northPanel.add(roomDisplay14);
- roomDisplay14.setColumns(5);
- roomDisplay14.setRows(5);
- roomDisplay14.setLineWrap(true);
- roomDisplay14.setText("Room 14");
- roomDisplay14.setEditable(false);
- roomDisplay14.setBackground(Color.green);
- JScrollPane scrollPane14 = new JScrollPane(roomDisplay14);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane14);
- northPanel.add(roomDisplay15);
- roomDisplay15.setColumns(5);
- roomDisplay15.setRows(5);
- roomDisplay15.setLineWrap(true);
- roomDisplay15.setText("Room 15");
- roomDisplay15.setEditable(false);
- roomDisplay15.setBackground(Color.green);
- JScrollPane scrollPane15 = new JScrollPane(roomDisplay15);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane15);
- northPanel.add(roomDisplay16);
- roomDisplay16.setColumns(5);
- roomDisplay16.setRows(5);
- roomDisplay16.setLineWrap(true);
- roomDisplay16.setText("Room 16");
- roomDisplay16.setEditable(false);
- roomDisplay16.setBackground(Color.green);
- JScrollPane scrollPane16 = new JScrollPane(roomDisplay16);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane16);
- northPanel.add(roomDisplay17);
- roomDisplay17.setColumns(5);
- roomDisplay17.setRows(5);
- roomDisplay17.setLineWrap(true);
- roomDisplay17.setText("Room 17");
- roomDisplay17.setEditable(false);
- roomDisplay17.setBackground(Color.green);
- JScrollPane scrollPane17 = new JScrollPane(roomDisplay17);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane17);
- northPanel.add(roomDisplay18);
- roomDisplay18.setColumns(5);
- roomDisplay18.setRows(5);
- roomDisplay18.setLineWrap(true);
- roomDisplay18.setText("Room 18");
- roomDisplay18.setEditable(false);
- roomDisplay18.setBackground(Color.green);
- JScrollPane scrollPane18 = new JScrollPane(roomDisplay18);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane18);
- northPanel.add(roomDisplay19);
- roomDisplay19.setColumns(5);
- roomDisplay19.setRows(5);
- roomDisplay19.setLineWrap(true);
- roomDisplay19.setText("Room 19");
- roomDisplay19.setEditable(false);
- roomDisplay19.setBackground(Color.green);
- JScrollPane scrollPane19 = new JScrollPane(roomDisplay19);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane19);
- northPanel.add(roomDisplay20);
- roomDisplay20.setColumns(5);
- roomDisplay20.setRows(5);
- roomDisplay20.setLineWrap(true);
- roomDisplay20.setText("Room 20");
- roomDisplay20.setEditable(false);
- roomDisplay20.setBackground(Color.green);
- JScrollPane scrollPane20 = new JScrollPane(roomDisplay20);
- scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scrollPane1.setPreferredSize(new Dimension(30,30));
- northPanel.add(scrollPane20);
- JPanel centerPanel = new JPanel();
- centerPanel.setLayout(new GridLayout(3,6,10,10));
- centerPanel.add(name);
- centerPanel.add(nameField);
- centerPanel.add(phone);
- centerPanel.add(phoneField);
- centerPanel.add(vehicle);
- centerPanel.add(vehicleField);
- centerPanel.add(address);
- centerPanel.add(addressField);
- centerPanel.add(checkin);
- centerPanel.add(checkinField);
- centerPanel.add(business);
- centerPanel.add(businessField);
- centerPanel.add(tariff);
- centerPanel.add(tariffField);
- centerPanel.add(deposit);
- centerPanel.add(depositField);
- centerPanel.add(checkout);
- centerPanel.add(checkoutField);
- Container c = getContentPane();
- c.setLayout(new BorderLayout(10,10));
- c.add(northPanel,BorderLayout.NORTH);
- c.add(centerPanel,BorderLayout.CENTER);
- c.add(bottomPanel,BorderLayout.SOUTH);
- return c;
- }//end of container pane
- public void actionPerformed(ActionEvent e)
- {
- String arg = e.getActionCommand();
- if(arg == "1")
- {
- roomDisplay1.setBackground(Color.red);
- roomDisplay1.setText("Room 1"+"\nName: "+
- nameField.getText()+"\nPhone number: "+
- phoneField.getText()+"\nVehicle registration number: "+
- vehicleField.getText()+"\nCustomers address: "+
- addressField.getText()+"\nCheck in: "+
- checkinField.getText()+"\nType of stay: "+
- businessField.getText()+"\nTariff: "+
- tariffField.getText()+"\nDeposit: "+
- depositField.getText()+"\nCheckout: "+
- checkoutField.getText()
- );
- }
- }
- public static void main(String[] args)
- {
- JFrame.setDefaultLookAndFeelDecorated(true);
- LenzHotel f = new LenzHotel();
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- f.setContentPane(f.createContentPane());
- f.setSize(700,500);
- f.setVisible(true);
- }//end of main method
- }//end of main costructor method