private void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20);
   contentPane.setBorder(border1);
   contentPane.setLayout(borderLayout1);
   controlsPane.setLayout(gridLayout1);
   gridLayout1.setColumns(1);
   gridLayout1.setHgap(10);
   gridLayout1.setRows(0);
   gridLayout1.setVgap(10);
   okButton.setVerifyInputWhenFocusTarget(true);
   okButton.setMnemonic('O');
   okButton.setText("OK");
   buttonsPane.setLayout(flowLayout1);
   flowLayout1.setAlignment(FlowLayout.CENTER);
   messagePane.setEditable(false);
   messagePane.setText("");
   borderLayout1.setHgap(10);
   borderLayout1.setVgap(10);
   this.setTitle("Subscription Authorization");
   this.getContentPane().add(contentPane, BorderLayout.CENTER);
   contentPane.add(controlsPane, BorderLayout.SOUTH);
   controlsPane.add(responsesComboBox, null);
   controlsPane.add(buttonsPane, null);
   buttonsPane.add(okButton, null);
   contentPane.add(messageScrollPane, BorderLayout.CENTER);
   messageScrollPane.getViewport().add(messagePane, null);
 }
  private void initComponents() {
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    messagePane.setBackground(contentPane.getBackground());
    messagePane.setEditorKit(new HTMLEditorKit());
    messagePane.setForeground(contentPane.getForeground());

    setSize(450, 360);

    // center the window
    int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth()) / 2;
    int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - getHeight()) / 2;
    setLocation(x, y);

    okButton.addActionListener(this);
  }
  public Payment() {
    super("Payment Process", false, true, false, true);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    label1 = new JLabel("Paymnent Number");
    label2 = new JLabel("Passenger Number");
    label3 = new JLabel("Passenger Name");
    label6 = new JLabel("Mode of Payment");
    label4 = new JLabel("Date of Payment");
    label5 = new JLabel("Amount Paid");
    label7 = new JLabel("Received By");
    text1 = new JTextField(10);
    text5 = new JTextField(10);
    p_date = new DateButton();
    p_date.setForeground(Color.red);
    combo1 = new JComboBox();
    combo2 = new JComboBox();
    combo3 = new JComboBox();
    combo4 = new JComboBox();

    combo4.addItem("Cash");
    combo4.addItem("Bank");
    combo8 = new JComboBox();
    button1 =
        new JButton("Pay", new ImageIcon(ClassLoader.getSystemResource("Images/payments.png")));
    button2 =
        new JButton(
            "Print Receipt", new ImageIcon(ClassLoader.getSystemResource("Images/print.png")));
    button3 =
        new JButton("Cancel", new ImageIcon(ClassLoader.getSystemResource("Images/exit.png")));
    button4 =
        new JButton("Search", new ImageIcon(ClassLoader.getSystemResource("Images/search.png")));
    button5 =
        new JButton("Delete", new ImageIcon(ClassLoader.getSystemResource("Images/delete.png")));
    // combo3.addItem(new)
    panel1 = new JPanel(new GridLayout(7, 2));
    panel1.setPreferredSize(new Dimension(350, 250));
    panel1.add(label1);
    panel1.add(text1);
    panel1.add(label2);
    panel1.add(combo1);
    panel1.add(label3);
    panel1.add(combo2);
    panel1.add(label6);
    panel1.add(combo4);
    panel1.add(label4);
    panel1.add(p_date);
    panel1.add(label5);
    panel1.add(combo8);
    panel1.add(label7);
    panel1.add(combo3);
    // combo8.removeAllItems();
    pane = new JPanel();
    pane.add(button1);

    pane.add(button2);
    pane.add(button3);
    pane.add(button4);

    panel3 = new JPanel();
    panel3.add(panel1);
    panel3.add(pane);

    button2.setEnabled(false);
    add(panel3);
    setSize(500, 350);
    setCombo();
    setcbr();
    generator();
    setamount();
    setLocation((screen.width - 300) / 2, ((screen.height - 300) / 2));
    setResizable(false);
    combo1.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            combo2.setSelectedIndex(combo1.getSelectedIndex());
            combo8.removeItem(combo8.getSelectedItem());
            setamount();
          }
        });

    button3.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            setVisible(true);
            dispose();
          }
        });
    button2.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            Receipt frm = new Receipt();
            MDIWindow.desktop.add(frm);
            frm.setVisible(true);
            button2.setEnabled(false);
          }
        });

    button1.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {

            if (combo1.getSelectedItem() == null) {
              JOptionPane.showMessageDialog(
                  null, "All Passenger have paid", "Error", JOptionPane.DEFAULT_OPTION);
              return;
            }
            if (combo2.getSelectedItem() == null) {
              JOptionPane.showMessageDialog(
                  null, "All Passenger have paid", "Error", JOptionPane.DEFAULT_OPTION);
              return;
            }
            generator();

            if (combo8.getSelectedItem() == null) {
              JOptionPane.showMessageDialog(
                  null, "The Passenger has not been booked", "ERROR", JOptionPane.DEFAULT_OPTION);
              return;
            }
            try {
              Statement statement = DBConnection.getDBConnection().createStatement();
              {
                String temp =
                    "INSERT INTO Payment (Payment_No, Pass_No, Pass_Name, Payment_Mode, Date_Payment,Amount_Paid,Received_By) VALUES ('"
                        + text1.getText()
                        + "', '"
                        + combo1.getSelectedItem()
                        + "', '"
                        + combo2.getSelectedItem()
                        + "', '"
                        + combo4.getSelectedItem()
                        + "', '"
                        + p_date.getText()
                        + "', '"
                        + combo8.getSelectedItem()
                        + "', '"
                        + combo3.getSelectedItem()
                        + "')";
                combo1.removeItem(combo1.getSelectedItem());
                combo2.removeItem(combo2.getSelectedItem());
                int result = statement.executeUpdate(temp);
                JOptionPane.showMessageDialog(
                    null, "Passenger Account updated", "Updated", JOptionPane.DEFAULT_OPTION);
              }

            } catch (SQLException sqlex) {
              sqlex.printStackTrace();
            }
            try {
              Statement statement = DBConnection.getDBConnection().createStatement();
              {
                String temp =
                    "UPDATE Passenger SET Pay_Status='Paid'"
                        + "WHERE Pass_NO LIKE  '"
                        + combo1.getSelectedItem()
                        + "'";
                int result = statement.executeUpdate(temp);
              }

            } catch (SQLException sqlex) {
              sqlex.printStackTrace();
            }
            button1.setEnabled(false);
            button2.setEnabled(true);
          }
        });
    button4.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            try {
              if (!text1.equals("")) {

                Statement statement = DBConnection.getDBConnection().createStatement();
                String query =
                    ("SELECT * FROM Payment where Payment_No ='" + text1.getText() + "'");

                ResultSet rs = statement.executeQuery(query);
                display(rs);
                statement.close();
              }
            } catch (SQLException sqlex) {
              sqlex.printStackTrace();
            }
            setVisible(true);
          }
        });
  }