private class LogReserve extends JFrame{ 
      public LogReserve(){
          setTitle("Hotel Reservation");
        setLayout(null);
          lblNTitle1 =new JLabel("RESERVATION SYSTEM");
        lblNTitle1.setBounds(220,5,150,40);
         lblNTitle1.setBackground(Color.DARK_GRAY);
        lblNTitle1.setForeground(Color.BLACK);
        add(lblNTitle1);
          JLabel lblUsername =new JLabel("First Name:");
        lblUsername.setBounds(55,30,80,40);
        lblUsername.setForeground(Color.DARK_GRAY);
        add(lblUsername);
        txtUsername=new JTextField("");
        txtUsername.setBounds(130,39,150,22);
        add(txtUsername);
        JLabel lbllastname =new JLabel("Last Name:");
            lbllastname.setBounds(310,30,80,40);
        lbllastname.setForeground(Color.DARK_GRAY);
        add(lbllastname);
        txtlastname=new JTextField("");
        txtlastname.setBounds(390,40,150,22);
        add(txtlastname);
         JLabel lblBirthd =new JLabel("Check In Date:");
            lblBirthd.setBounds(55,70,90,40);
        lblBirthd.setForeground(Color.DARK_GRAY);
        add(lblBirthd);
        String [] strMonth = {"Month","January", "February", "March", "April","May","June","July","August","September","October","November","December"};
        JComboBox comboMonth = new JComboBox(strMonth);
        comboMonth.setBounds(220,80,100,22);
        add(comboMonth);  
        String [] strDate = {"Date","01", "02", "03", "04","05","06","07","08","09","10"};
        JComboBox comboDate = new JComboBox(strDate);
        comboDate.setBounds(150,80,60,22);
        add(comboDate);   
        String [] strYear = {"Year","2000", "1999", "1998", "1997","1996","1995","1994","1993","1992","1991","1990"};
        JComboBox comboYear = new JComboBox(strYear);
        comboYear.setBounds(330,80,60,22);
        add(comboYear);
        JLabel lblAdd = new JLabel("E-mail Address:");  
        lblAdd.setBounds(55,110,90,40);
        lblAdd.setForeground(Color.DARK_GRAY);
        add(lblAdd);
         txtAdd = new JTextField("  ");
        txtAdd.setBounds(150,120,150,22);
        add(txtAdd);
          JLabel lblNation = new JLabel("Nationality:");  
        lblNation.setBounds(310,110,90,40);
        lblNation.setForeground(Color.DARK_GRAY);
        add(lblNation);
         txtNation = new JTextField("  ");
        txtNation.setBounds(390,120,150,22);
        add(txtNation);
        JLabel lblCity = new JLabel("City:");  
        lblCity.setBounds(310,150,80,40);
        lblCity.setForeground(Color.DARK_GRAY);
        add(lblCity);
         txtCity = new JTextField("");
        txtCity.setBounds(390,160,150,22);
        add(txtCity);
          JLabel lblcountry1 = new JLabel("Mode of Payment:");  
        lblcountry1.setBounds(55,150,110,40);
        lblcountry1.setForeground(Color.DARK_GRAY);
        add(lblcountry1); 
         JRadioButton optCredit = new JRadioButton("Credit Card");
         optCredit.setBounds(155,160,90,15);
        add(optCredit);
        JRadioButton optCash = new JRadioButton ("Cash");
        optCash.setBounds(242,160,60,15);
        add(optCash);
        ButtonGroup optGender = new ButtonGroup();
        optGender.add(optCredit);
        optGender.add(optCash);
         JLabel lblMobile = new JLabel("Mobile No. :");  
        lblMobile.setBounds(55,190,80,40);
        lblMobile.setForeground(Color.DARK_GRAY);
        add(lblMobile);
         txtMobile = new JTextField("+639");
        txtMobile.setBounds(130,200,120,22);
        add(txtMobile);
         JLabel lblRoomNum = new JLabel("Room No. :");  
        lblRoomNum.setBounds(310,190,80,40);//300,160,90,80
        lblRoomNum.setForeground(Color.DARK_GRAY);
        add(lblRoomNum);
         txtRoomNum = new JTextField("");
        txtRoomNum.setBounds(400,200,80,22);//300,220,200,25
        add(txtRoomNum);
         JLabel lblRoomT = new JLabel("Room Type:");  
        lblRoomT.setBounds(55,230,80,40);
        lblRoomT.setForeground(Color.DARK_GRAY);
        add(lblRoomT);
        String [] strRoom1 = {"Single", "Double", "Triple", "Quad"};
        JComboBox comboRoom1 = new JComboBox(strRoom1);
        comboRoom1.setBounds(131,240,100,22);
        add(comboRoom1);
          JLabel lblPerson = new JLabel("No. of Person:");  
        lblPerson.setBounds(310,230,80,40);
        lblPerson.setForeground(Color.DARK_GRAY);
        add(lblPerson);
           txtPerson = new JTextField("");
        txtPerson.setBounds(400,240,80,22);
        add(txtPerson);
          JLabel lblCout =new JLabel("Check Out Date:");
            lblCout.setBounds(55,270,100,40);
        lblCout.setForeground(Color.DARK_GRAY);
        add(lblCout);
        String [] strMonth1 = {"Month","January", "February", "March", "April","May","June","July","August","September","October","November","December"};
        JComboBox comboMonth1 = new JComboBox(strMonth);
        comboMonth1.setBounds(225,280,100,22);
        add(comboMonth1);  
        String [] strDate1 = {"Date","01", "02", "03", "04","05","06","07","08","09","10"};
        JComboBox comboDate1 = new JComboBox(strDate);
        comboDate1.setBounds(155,280,60,22);
        add(comboDate1);   
        String [] strYear1 = {"Year","2000", "1999", "1998", "1997","1996","1995","1994","1993","1992","1991","1990"};
        JComboBox comboYear1 = new JComboBox(strYear);
        comboYear1.setBounds(335,280,60,22);
        add(comboYear1);
          JLabel lblChoose = new JLabel("Choose Type:");  
        lblChoose.setBounds(50,310,80,40);//300,160,90,80
        lblChoose.setForeground(Color.DARK_GRAY);
        add(lblChoose);
        btnReserve = new JButton("Reserve");
        btnReserve.setBounds(120,360,85,25);
        add(btnReserve);
        btnCReserve = new JButton("Cancel Reservation");
        btnCReserve.setBounds(215,360,150,25);
        add(btnCReserve);
        btnCancel1 = new JButton("Clear");
        btnCancel1.setBounds(375,360,85,25);
        add(btnCancel1);
        ActionListener listener = new ButtonListener();
        btnReserve.addActionListener(listener);
        btnCReserve.addActionListener(listener);
         btnCancel1.addActionListener(listener);
        setSize(600,500);
        setVisible(true);   
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
      public class ButtonListener implements ActionListener {
        public void actionPerformed(ActionEvent evt) {
            JButton source = (JButton) evt.getSource();
            if (source == btnReserve) {
                int answer = JOptionPane.showConfirmDialog(null, "Comfirm Reservation?", "Confirm Dialog", JOptionPane.YES_NO_OPTION);
                switch (answer) {
                    case JOptionPane.YES_OPTION:
                         JOptionPane.showMessageDialog(
                        null,
                        "Reserved!",
                        "Successful", JOptionPane.PLAIN_MESSAGE);
                        break;
                   case JOptionPane.NO_OPTION:
                        break;          
                }
            }
            else if(source == btnCReserve){
                JOptionPane.showConfirmDialog(null, "Cancel Reservation?", "Confirm Dialog", JOptionPane.YES_NO_OPTION);
            }
else if(source == btnCancel1) {
                txtUsername.setText("");
                txtlastname.setText("");
               txtAdd.setText("");
               txtCity.setText("");
              txtMobile.setText("+639");
               txtRoomNum.setText("");
              txtPerson.setText("");
              txtNation.setText("");
            }
                }
            }
     } 
   private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {
  if(evt.getKeyCode() == KeyEvent.VK_ENTER) {
      // Enter was pressedsd. Your code goes here.dsad
      if(Susername.equals("tip")  && Spassword.equals("abet")){
                   //ImageIcon icon = new ImageIcon(Login.class.getResource("Images/sm.png"));
                       JOptionPane.showMessageDialog(
                        null,
                        "Welcome!",
                        "Login Successful", JOptionPane.PLAIN_MESSAGE
                        );
            btnlogin1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            JFrame secondFrame = new JFrame();  
            secondFrame.setSize(600, 500);  
            secondFrame.setVisible(true);  
            }});  
                }
   }
} 

how to save input data to database when i click the reserve button?

First of all when the button is pressed you want to make a connection to the database you are storing the information to. You would probably use JDBC to accomplish this. Then you would proceed to retrieve the data and store it in the correct fields through the connection. Once all the data has been written you will close the stream. Take a look at these examples.

Example 1
Example 2

This should help you get started.

This article has been dead for over six months. Start a new discussion instead.