private void initGUI() {

    JPanel pCommand = new JPanel();

    pResult = new JPanel();
    nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult);

    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());

    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new JTextArea(5, 40);

    txtCommand.setMargin(new Insets(5, 5, 5, 5));
    txtCommand.addKeyListener(this);

    txtCommandScroll = new JScrollPane(txtCommand);
    txtResult = new JTextArea(20, 40);

    txtResult.setMargin(new Insets(5, 5, 5, 5));

    txtResultScroll = new JScrollPane(txtResult);

    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
    /*
    // button replaced by toolbar
            butExecute = new JButton("Execute");

            butExecute.addActionListener(this);
            pCommand.add(butExecute, BorderLayout.EAST);
    */
    pCommand.add(txtCommandScroll, BorderLayout.CENTER);

    gResult = new GridSwing();
    gResultTable = new JTable(gResult);
    gScrollPane = new JScrollPane(gResultTable);

    // getContentPane().setLayout(new BorderLayout());
    pResult.add(gScrollPane, BorderLayout.CENTER);

    // Set up the tree
    rootNode = new DefaultMutableTreeNode("Connection");
    treeModel = new DefaultTreeModel(rootNode);
    tTree = new JTree(treeModel);
    tScrollPane = new JScrollPane(tTree);

    tScrollPane.setPreferredSize(new Dimension(120, 400));
    tScrollPane.setMinimumSize(new Dimension(70, 100));
    txtCommandScroll.setPreferredSize(new Dimension(360, 100));
    txtCommandScroll.setMinimumSize(new Dimension(180, 100));
    gScrollPane.setPreferredSize(new Dimension(460, 300));

    ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane);

    fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);
    doLayout();
    fMain.pack();
  }
Esempio n. 2
0
  public AddNewStudent() // constructor
      {
    // initializing buttons
    btnok = new JButton("OK");
    btnok.addActionListener(this);
    btnexit = new JButton("Exit");
    btnexit.addActionListener(this);
    btnaddnew = new JButton("AddNew");
    btnaddnew.addActionListener(this);

    // initializing textfields
    tf1 = new JTextField(12);
    tf2 = new JTextField(12);
    // initializing labels

    lblname = new JLabel("Name:");
    lbladd = new JLabel("Address:");
    lblmsg = new JLabel("", JLabel.CENTER);

    // initializing panels
    p1 = new JPanel();
    p2 = new JPanel();
    p3 = new JPanel();
    psouth = new JPanel();

    // adding buttons and label to panel p1
    // setting flowlayout
    p1.setLayout(new FlowLayout());

    p1.add(btnok);
    p1.add(btnexit);
    p1.add(btnaddnew);
    // adding lblmsg to panel p3
    p3.add(lblmsg);

    // adding both the panels to new panel,psouth
    // settin layout 2:1
    psouth.setLayout(new GridLayout(2, 1));
    psouth.add(p3);
    psouth.add(p1);

    // adding label and textfields to panel p2
    p2.setLayout(new GridLayout(3, 1));
    // setting line and titled border for panel p2
    p2.setBorder(BorderFactory.createLineBorder(Color.red));
    p2.setBorder(BorderFactory.createTitledBorder("Enter Your Details"));
    p2.add(lblname);
    p2.add(tf1);
    p2.add(lbladd);
    p2.add(tf2);

    // adding panel to container
    this.getContentPane().add(p2, "Center");
    this.getContentPane().add(psouth, "South");

    this.setSize(300, 300);
    this.setLocation(100, 200);
    this.show();
  }
 private void setup() {
   setSize(600, 400);
   JPanel panel = new JPanel();
   panel.add(new JScrollPane(ta));
   panel.add(tf);
   panel.add(send);
   panel.add(logout);
   panel.add(refresh);
   add(panel);
   setVisible(true);
 }
 // --------初始化界面的方法---------
 public void init() {
   JPanel top = new JPanel();
   top.add(new JLabel("输入查询语句:"));
   top.add(sqlField);
   top.add(execBn);
   // 为执行按钮、单行文本框添加事件监听器
   execBn.addActionListener(new ExceListener());
   sqlField.addActionListener(new ExceListener());
   jf.add(top, BorderLayout.NORTH);
   jf.setSize(680, 480);
   jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   jf.setVisible(true);
 }
Esempio n. 5
0
  private void jbInit() throws Exception {
    setTitle("users");
    buttonsPanel.setLayout(flowLayout1);
    flowLayout1.setAlignment(FlowLayout.LEFT);
    this.setSize(new Dimension(500, 300));
    grid.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    grid.setDeleteButton(deleteButton);
    grid.setExportButton(exportButton1);
    grid.setFunctionId("USERS");
    grid.setInsertButton(null);
    grid.setNavBar(navigatorBar1);
    grid.setReloadButton(reloadButton);
    grid.setInsertButton(insertButton);
    grid.setValueObjectClassName("demo38.UserVO");
    colUsername.setColumnFilterable(true);
    colUsername.setColumnName("username");
    colUsername.setUpperCase(true);
    colUsername.setTrimText(true);
    colUsername.setColumnSortable(true);
    colPassword.setColumnName("password");
    colPassword.setEncryptText(true);
    colDescription.setColumnName("description");
    colDescription.setPreferredWidth(350);
    colDescription.setEditableOnEdit(true);
    colDescription.setEditableOnInsert(true);
    colUsername.setEditableOnEdit(false);
    colUsername.setEditableOnInsert(true);
    colPassword.setEditableOnEdit(true);
    colPassword.setEditableOnInsert(true);
    insertButton.setText("insertButton1");
    grid.setSaveButton(saveButton);
    grid.setEditButton(editButton);
    exportButton1.setText("exportButton1");
    this.getContentPane().add(grid, BorderLayout.CENTER);
    this.getContentPane().add(buttonsPanel, BorderLayout.NORTH);
    buttonsPanel.add(insertButton, null);
    buttonsPanel.add(editButton, null);
    buttonsPanel.add(saveButton, null);
    buttonsPanel.add(reloadButton, null);
    buttonsPanel.add(deleteButton, null);
    buttonsPanel.add(exportButton1, null);
    buttonsPanel.add(navigatorBar1, null);

    grid.getColumnContainer().add(colUsername, null);
    grid.getColumnContainer().add(colPassword, null);
    grid.getColumnContainer().add(colDescription, null);
  }
Esempio n. 6
0
  public hostelStatus() {
    setTitle("Hostel");
    connect();
    updateRecord();

    JFrame fr = new JFrame();
    Toolkit tkt = fr.getToolkit();
    Dimension frsize = tkt.getScreenSize();
    setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8);
    setLayout(null);

    cn = getContentPane();
    cn.setBackground(new Color(190, 180, 170));

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    tl = new JLabel("Current Hostels Status");
    tl.setFont(new Font("Engravers MT", 1, 25));
    tl.setForeground(new Color(247, 251, 249));

    p1 = new JPanel();
    p1.setBounds(0, 0, 600, 50);
    p1.add(tl);
    p1.setBackground(new Color(31, 88, 166));
    cn.add(p1);

    b1 = new JButton("LOAD");
    b1.setMnemonic('L');
    b1.addActionListener(new dispListener());
    b1.setBounds(230, 320, 120, 30);

    b2 = new JButton("EXIT");
    b2.setMnemonic('X');
    b2.addActionListener(new exitListener());
    b2.setBounds(350, 320, 100, 30);

    cn.add(b1);
    cn.add(b2);

    table = new JTable(data, col);
    table.setFont(new Font("Serif", Font.BOLD, 16));
    table.setBackground(new Color(250, 250, 250));
    table.setEnabled(false);

    JScrollPane jsp = new JScrollPane(table);
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBounds(5, 100, 590, 200);
    cn.add(jsp);

    screensize = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(600, 400);
    setVisible(true);
    setVisible(true);
    setResizable(true);
    connect();
  }
Esempio n. 7
0
 private void jbInit() throws Exception {
   grid.setAnchorLastColumn(true);
   buttonsPanel.setLayout(flowLayout1);
   flowLayout1.setAlignment(FlowLayout.LEFT);
   grid.setDeleteButton(deleteButton);
   grid.setExportButton(exportButton1);
   grid.setFilterButton(filterButton1);
   grid.setFunctionId("getEmployees");
   grid.setInsertButton(null);
   grid.setNavBar(navigatorBar1);
   grid.setReloadButton(reloadButton);
   grid.setValueObjectClassName("demo36.EmpVO");
   colEmpCode.setColumnFilterable(true);
   colEmpCode.setColumnName("empCode");
   colEmpCode.setColumnSortable(false);
   colFName.setColumnFilterable(true);
   colFName.setColumnName("firstName");
   colFName.setColumnSortable(true);
   colFName.setPreferredWidth(150);
   insertButton.setText("insertButton1");
   insertButton.addActionListener(new EmpGridFrame_insertButton_actionAdapter(this));
   exportButton1.setText("exportButton1");
   colLName.setColumnFilterable(true);
   colLName.setColumnName("lastName");
   colLName.setPreferredWidth(150);
   filterButton1.setText("filterButton1");
   this.getContentPane().add(grid, BorderLayout.CENTER);
   this.getContentPane().add(buttonsPanel, BorderLayout.NORTH);
   buttonsPanel.add(insertButton, null);
   buttonsPanel.add(reloadButton, null);
   buttonsPanel.add(deleteButton, null);
   buttonsPanel.add(exportButton1, null);
   buttonsPanel.add(filterButton1, null);
   buttonsPanel.add(navigatorBar1, null);
   grid.getColumnContainer().add(colEmpCode, null);
   grid.getColumnContainer().add(colFName, null);
   grid.getColumnContainer().add(colLName, null);
 }
  private void showHelp(String help[]) {

    txtCommand.setText(help[0]);

    bHelp = true;

    pResult.removeAll();
    pResult.add(txtResultScroll, BorderLayout.CENTER);
    pResult.doLayout();
    txtResult.setText(help[1]);
    pResult.repaint();
    txtCommand.requestFocus();
    txtCommand.setCaretPosition(help[0].length());
  }
Esempio n. 9
0
  LoginForm() {
    setDefaultLookAndFeelDecorated(true);
    f = new JFrame("LoginForm");
    f.setSize(750, 330);
    f.setLocation(200, 200);
    f.setResizable(false);
    JPanel p = new JPanel();
    f.getContentPane().add(p);
    p.setBackground(Color.white);
    icon = new ImageIcon("img.jpg");
    image = new JLabel(icon);
    image.setSize(100, 100);
    l2 = new JLabel("�");
    t1 = new JTextField(16);
    l3 = new JLabel("Password");
    jp1 = new JPasswordField(16);
    // img = getImage(getDocumentBase(), getParameter("img"));

    b1 = new JButton("Login");
    b2 = new JButton("Reset");
    b3 = new JButton("Cancel");
    l1 = new JLabel("       SANJEEVANI HOSPITAL");
    Font fk = new Font("Algerian", Font.BOLD, 40);
    l1.setFont(fk);
    l1.setForeground(Color.RED);
    l2 = new JLabel("UserName");
    l4 = new JLabel("�                                              ");

    p.add(l1);
    p.add(l4);
    p.add(l2);

    p.add(t1);

    p.add(l3);
    p.add(jp1);

    p.add(b1);
    p.add(b2);
    p.add(b3);
    p.add(image, BorderLayout.SOUTH);
    b1.addActionListener(this);
    b2.addActionListener(this);
    b3.addActionListener(this);

    f.setVisible(true);
  }
Esempio n. 10
0
  public TableDeneme() {
    super("Dictionary Window");
    qtm = new QueryTableModel();
    table = new JTable(qtm);
    scrollpane = new JScrollPane(table);
    p1 = new JPanel();
    jb = new JButton("get em all");
    p1.add(jb);

    getContentPane().add(p1, BorderLayout.NORTH);
    getContentPane().add(scrollpane, BorderLayout.CENTER);
    addWindowListener(new BasicWindowMonitor());
    setSize(500, 500);
    setVisible(true);

    JOptionPane.showMessageDialog(
        new Frame(),
        "Press the button,\n"
            + "It will fill the table with all records.\n"
            + "Then you can edit the cells.\n"
            + "When you select another cell, the previous one will updated.\n\n"
            + "*****@*****.**");

    /**
     * ****show selection***** table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); rowSM =
     * table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener(){ public
     * void valueChanged(ListSelectionEvent e){ if (e.getValueIsAdjusting()) return;
     * ListSelectionModel lsm = (ListSelectionModel)e.getSource(); if (lsm.isSelectionEmpty()){
     * System.out.println("No rows are selected."); } else{
     * System.out.println(table.getValueAt(table.getSelectionModel().getMinSelectionIndex(),0));
     * System.out.println(table.getValueAt(table.getSelectionModel().getMinSelectionIndex(),1)); } }
     * }); ********************
     */
    jb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            qtm.setHostURL(
                "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL=MS Access;DriverId=281;DBQ=db1.mdb");
            qtm.setQuery("select * from soz");
          }
        });
  }
  private void updateResult() {

    if (iResult == 0) {

      // in case 'help' has removed the grid
      if (bHelp) {
        pResult.removeAll();
        pResult.add(gScrollPane, BorderLayout.CENTER);
        pResult.doLayout();
        gResult.fireTableChanged(null);
        pResult.repaint();

        bHelp = false;
      }
    } else {
      showResultInText();
    }

    txtCommand.selectAll();
    txtCommand.requestFocus();
  }
  public void actionPerformed(ActionEvent e) {
    JButton b = (JButton) e.getSource();
    if (b == bu) {
      j14 = new JLabel("NEW IMAGE");
      j14.setBounds(840, 200, 300, 300);
      q.add(j14);

      JFileChooser filechooser = new JFileChooser();
      int result = filechooser.showOpenDialog(this);
      f = filechooser.getSelectedFile();
      try {
        String dir1 = f.getAbsolutePath();
        // setText(dir);
        str = dir1;
        // ResizeImage.resize(dir);
        f = new File(dir1);
      } catch (Exception e1) {
      }
      repaint();
      // b=(JButton)e.getSource();

    }
    if (b == ba) {
      try {
        read();
        patient.add(tadd.getText(), tsym.getText(), f, str);
        JOptionPane.showMessageDialog(null, "Patient ID: " + patient.pid + " Record Added");
      } catch (Exception e4) {
        System.out.println("" + e4);
      }
    }
    if (b == bm) {
      try {
        setVisible(false);
      } catch (Exception e4) {
        System.out.println("" + e4);
      }
    }
  }
Esempio n. 13
0
  public MakeReservation() {
    new BorderLayout();

    standardRoom.setMnemonic(KeyEvent.VK_K);
    standardRoom.setActionCommand("Standard Room");
    standardRoom.setSelected(true);

    familyRoom.setMnemonic(KeyEvent.VK_F);
    familyRoom.setActionCommand("Family Room");

    suiteRoom.setMnemonic(KeyEvent.VK_S);
    suiteRoom.setActionCommand("Suite");

    // Add Booking Button
    ImageIcon bookRoomIcon = createImageIcon("images/book.png");
    bookRoom = new JButton("Book Room", bookRoomIcon);
    bookRoom.setVerticalTextPosition(AbstractButton.BOTTOM);
    bookRoom.setHorizontalTextPosition(AbstractButton.CENTER);
    bookRoom.setMnemonic(KeyEvent.VK_M);
    bookRoom.addActionListener(this);
    bookRoom.setActionCommand("book");

    // Group the radio buttons.
    group.add(standardRoom);
    group.add(familyRoom);
    group.add(suiteRoom);

    // Create the labels.
    nameLabel = new JLabel("Name: ");
    amountroomsLabel = new JLabel("How many rooms? ");
    checkoutdateLabel = new JLabel("Check-Out Date: ");
    checkindateLabel = new JLabel("Check-In Date: ");

    // Create the text fields and set them up.
    nameField = new JFormattedTextField();
    nameField.setColumns(10);

    amountroomsField = new JFormattedTextField(new Integer(1));
    amountroomsField.setValue(new Integer(1));
    amountroomsField.setColumns(10);

    // java.util.Date dt_checkin = new java.util.Date();
    LocalDate today = LocalDate.now();
    // java.text.SimpleDateFormat sdf_checkin = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkin = today.toString();
    checkindateField = new JFormattedTextField(currentDate_checkin);
    checkindateField.setColumns(10);

    // java.util.Date dt_checkout = new java.util.Date();
    LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
    // java.text.SimpleDateFormat sdf_checkout = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkout = tomorrow.toString();
    checkoutdateField = new JFormattedTextField(currentDate_checkout);
    checkoutdateField.setColumns(10);

    // Tell accessibility tools about label/textfield pairs.
    nameLabel.setLabelFor(nameField);
    amountroomsLabel.setLabelFor(amountroomsField);
    checkoutdateLabel.setLabelFor(checkoutdateField);
    checkindateLabel.setLabelFor(checkindateField);

    // Lay out the labels in a panel.
    JPanel labelPane1 = new JPanel(new GridLayout(0, 1));

    labelPane1.add(amountroomsLabel);

    JPanel labelPane3 = new JPanel(new GridLayout(0, 1));
    labelPane3.add(checkindateLabel);

    JPanel labelPane2 = new JPanel(new GridLayout(0, 1));
    labelPane2.add(checkoutdateLabel);

    JPanel labelPane4 = new JPanel(new GridLayout(0, 1));
    labelPane4.add(nameLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane1 = new JPanel(new GridLayout(0, 1));
    fieldPane1.add(amountroomsField);

    JPanel fieldPane3 = new JPanel(new GridLayout(0, 1));
    fieldPane3.add(checkindateField);

    JPanel fieldPane2 = new JPanel(new GridLayout(0, 1));
    fieldPane2.add(checkoutdateField);

    JPanel fieldPane4 = new JPanel(new GridLayout(0, 1));
    fieldPane4.add(nameField);

    // Put the radio buttons in a column in a panel.
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(standardRoom);
    radioPanel.add(familyRoom);
    radioPanel.add(suiteRoom);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane1, BorderLayout.LINE_START);
    add(fieldPane1, BorderLayout.LINE_END);
    add(labelPane3, BorderLayout.LINE_START);
    add(fieldPane3, BorderLayout.LINE_END);
    add(labelPane2, BorderLayout.LINE_START);
    add(fieldPane2, BorderLayout.LINE_END);
    add(labelPane4, BorderLayout.LINE_START);
    add(fieldPane4, BorderLayout.LINE_END);

    add(radioPanel, BorderLayout.LINE_END);
    add(bookRoom);
  }
  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);
          }
        });
  }
Esempio n. 15
0
  public CopyFileToTable() {
    JPanel jPane1 = new JPanel();
    jPane1.setLayout(new BorderLayout());
    jPane1.add(new JLabel("Filename"), BorderLayout.WEST);
    jPane1.add(jbtViewFile, BorderLayout.EAST);
    jPane1.add(jtfFilename, BorderLayout.CENTER);

    JPanel jPane2 = new JPanel();
    jPane2.setLayout(new BorderLayout());
    jPane2.setBorder(new TitledBorder("Source Text File"));
    jPane2.add(jPane1, BorderLayout.NORTH);
    jPane2.add(new JScrollPane(jtaFile), BorderLayout.CENTER);

    JPanel jPane3 = new JPanel();
    jPane3.setLayout(new GridLayout(5, 0));
    jPane3.add(new JLabel("JDBC Driver"));
    jPane3.add(new JLabel("Database URL"));
    jPane3.add(new JLabel("Username"));
    jPane3.add(new JLabel("Password"));
    jPane3.add(new JLabel("Table Name"));

    JPanel jPane4 = new JPanel();
    jPane4.setLayout(new GridLayout(5, 0));
    jcboDriver.setEditable(true);
    jPane4.add(jcboDriver);
    jcboURL.setEditable(true);
    jPane4.add(jcboURL);
    jPane4.add(jtfUsername);
    jPane4.add(jtfPassword);
    jPane4.add(jtfTableName);

    JPanel jPane5 = new JPanel();
    jPane5.setLayout(new BorderLayout());
    jPane5.setBorder(new TitledBorder("Target Database Table"));
    jPane5.add(jbtCopy, BorderLayout.SOUTH);
    jPane5.add(jPane3, BorderLayout.WEST);
    jPane5.add(jPane4, BorderLayout.CENTER);

    add(jlblStatus, BorderLayout.SOUTH);
    add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jPane2, jPane5), BorderLayout.CENTER);

    jbtViewFile.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            showFile();
          }
        });

    jbtCopy.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            try {
              copyFile();
            } catch (Exception ex) {
              jlblStatus.setText(ex.toString());
            }
          }
        });
  }
Esempio n. 16
0
  public void setContent(String cat) {
    cat = cat.trim();
    selectAllCB.setVisible(false);
    selectAllCB.setSelected(false);
    deleteBut.setVisible(false);
    restoreBut.setVisible(false);
    refreshBut.setVisible(true);
    Object columns[] = null;
    int count = 0;
    switch (cat) {
      case "Inbox":
        columns = new Object[] {"", "From", "Date", "Subject", "Content"};
        count = Database.getCount("Inbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc");
        ;
        break;
      case "SentMail":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Sentmail");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc");
        break;
      case "Draft":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Draft");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc");
        break;
      case "Outbox":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Outbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc");
        break;
      case "Trash":
        //                restoreBut.setVisible(true);
        columns = new Object[] {"", "To/From", "Date", "Subject", "Content"};
        count = Database.getCount("Trash");
        workingSet =
            db.getData(
                "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc");
        break;
      default:
        System.out.println("in default case");
    }
    if (count > 0) {
      selectAllCB.setVisible(true);
      rows = new Object[count][];
      msgID = new int[count];
      try {
        workingSet.beforeFirst();
        for (int i = 0; i < count && workingSet.next(); i++) {
          msgID[i] = workingSet.getInt(1);
          rows[i] =
              new Object[] {
                false,
                workingSet.getString(2),
                workingSet.getDate(3),
                workingSet.getString(4),
                workingSet.getString(5)
              };
        }
      } catch (SQLException sqlExc) {
        JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE);
        sqlExc.printStackTrace();
      }

      tableModel = new MyDefaultTableModel(rows, columns);
      table = new JTable(tableModel);
      table.getSelectionModel().addListSelectionListener(this);
      table.addMouseListener(this);
      table.getTableHeader().setOpaque(true);
      table.getTableHeader().setReorderingAllowed(false);
      //            table.getTableHeader().setBackground(Color.blue);
      table.getTableHeader().setForeground(Color.blue);
      //        table.setRowSelectionAllowed(false);
      //            table.setColumnSelectionAllowed(false);
      table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
      table.setRowHeight(20);
      table.setFillsViewportHeight(true);

      TableColumn column = null;
      for (int i = 0; i < 5; i++) {
        column = table.getColumnModel().getColumn(i);
        if (i == 0) {
          column.setPreferredWidth(6);
        } else if (i == 3) {
          column.setPreferredWidth(250);
        } else if (i == 4) {
          column.setPreferredWidth(450);
        } else {
          column.setPreferredWidth(40);
        }
      }
      table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

      remove(contentPan);
      contentPan = new JScrollPane(table);
      contentPan.setBackground(Color.orange);
      contentPan.setOpaque(true);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      Home.home.homeFrame.setVisible(true);
    } else {
      JPanel centPan = new JPanel(new GridBagLayout());
      centPan.setBackground(new Color(52, 86, 70));
      JLabel label = new JLabel("No Messages In This Category");
      label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22));
      label.setForeground(Color.orange);
      centPan.add(label);
      remove(contentPan);
      contentPan = new JScrollPane(centPan);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      contentPan.repaint();
    }
  }
Esempio n. 17
0
  public void createGUI() {
    setLayout(new BorderLayout());
    toolBar = new JToolBar("options", JToolBar.HORIZONTAL);
    toolBar.setFloatable(false);
    toolBar.setOpaque(true);
    toolBar.setBackground(new Color(154, 12, 12));
    toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15));
    selectAllCB = new JCheckBox("Select All");
    selectAllCB.setVisible(false);
    selectAllCB.setForeground(Color.white);
    selectAllCB.addActionListener(this);
    refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png")));
    refreshBut.setVisible(false);
    refreshBut.setToolTipText("Refresh");
    refreshBut.setForeground(new Color(20, 88, 49));
    refreshBut.addActionListener(this);
    backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png")));
    backBut.setVisible(false);
    backBut.setToolTipText("Back");
    backBut.setForeground(new Color(20, 88, 49));
    backBut.addActionListener(this);
    deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png")));
    deleteBut.setToolTipText("Delete");
    deleteBut.setForeground(Color.red);
    deleteBut.setVisible(false);
    deleteBut.addActionListener(this);
    deleteBut.setBackground(Color.red);
    restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png")));
    restoreBut.setToolTipText("Restore");
    restoreBut.setForeground(Color.blue);
    restoreBut.setVisible(false);
    restoreBut.addActionListener(this);
    toolBar.addSeparator(new Dimension(10, 5));
    toolBar.add(selectAllCB);
    toolBar.add(backBut);
    toolBar.add(refreshBut);
    toolBar.add(deleteBut);
    toolBar.add(restoreBut);
    add(toolBar, "North");
    JPanel centPan = new JPanel(new GridBagLayout());
    centPan.setBackground(new Color(52, 86, 70));
    JLabel label = new JLabel("Select A Category From Left Pane");
    label.setFont(new Font("arial", Font.BOLD, 35));
    label.setForeground(Color.yellow);
    centPan.add(label);
    contentPan = new JScrollPane(centPan);
    contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    add(contentPan, "Center");
    contentPan.repaint();

    db = new Database();
    //        inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id
    // desc");
    //        sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id
    // desc");
    //        draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id
    // desc");
    //        outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id
    // desc");
    //        trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and
    // messages.msg_id=trash.msg_id ORDER BY deleted_at desc");

  }
  public void focusLost(FocusEvent e) {
    int id = 0;
    boolean res = false;
    JTextField t = (JTextField) e.getSource();
    if (t == tpid) {
      try {
        id = Integer.parseInt(tpid.getText());
        res = patient.psearch(id);
      } catch (Exception e1) {
      }

      if (res) {
        int no, ag = 0, fee = 0;
        String pfn = "",
            bg = "",
            pmn = "",
            dt1 = "",
            pln = "",
            add = "",
            sym = "",
            dn = "",
            dig = "",
            cn = "",
            gender = "",
            wgt = "";
        try {
          dt1 = patient.rs.getString(1);
          no = patient.rs.getInt(2);
          pfn = patient.rs.getString(3);
          pmn = patient.rs.getString(4);
          pln = patient.rs.getString(5);
          gender = patient.rs.getString(6);
          ag = patient.rs.getInt(7);
          wgt = patient.rs.getString(8);
          add = patient.rs.getString(9);
          cn = patient.rs.getString(10);
          dn = patient.rs.getString(11);
          sym = patient.rs.getString(12);
          dig = patient.rs.getString(13);
          fee = patient.rs.getInt(14);
          bg = patient.rs.getString(15);
          dir = patient.rs.getString(17);

          s = dir;
          repaint();
          j13 = new JLabel("OLD IMAGE");
          j13.setBounds(840, 5, 300, 300);
          JLabel j12 =
              new JLabel("OLD PHOTO") {
                public void paint(Graphics g) {
                  ImageIcon ic = new ImageIcon(s);
                  Image img = ic.getImage();
                  g.drawImage(img, 0, 0, 150, 150, this);
                }
              };

          //	q.flushAll()

          /*ImageIcon ic=new ImageIcon(dir);
          JLabel j12=new JLabel("",ic,JLabel.CENTER);*/
          j12.setBounds(670, 70, 300, 300);
          //	image.setBounds(700,300,100,100);

          q.add(j12);
          q.add(j13);
          repaint();
          System.out.println("8743t32874" + dir);
        } catch (Exception e2) {
        }
        if (gender.equals("Male")) cm.setState(true);
        else cf.setState(true);
        tdt.setText(dt1);
        tpfnm.setText(pfn);
        tpmnm.setText(pmn);
        tplnm.setText(pln);
        tage.setText("" + ag);
        tfee.setText("" + fee);
        tadd.setText(add);
        tdig.setText(dig);
        tdnm.setText(dn);
        tsym.setText(sym);
        tcno.setText(cn);
        twt.setText(wgt);
        tbg.setText(bg);

        // cm.setState(set1State());
        // cf.setSelectedCheckbox(gender);
        ba.setEnabled(false);
        bm.setEnabled(true);
        bd.setEnabled(true);
      } else {
        if (id == 0) {
          bl.setEnabled(true);
          ba.setEnabled(false);
        } else ba.setEnabled(true);
        bm.setEnabled(false);
        bd.setEnabled(false);
      }
    }
  }
Esempio n. 19
0
  public EchoAWT() throws UnknownHostException {

    super("채팅 프로그램");

    // 각종 정의
    h = new JPanel(new GridLayout(2, 3));
    m = new JPanel(new BorderLayout());
    f = new JPanel(new BorderLayout());
    s = new JPanel(new BorderLayout());
    login = new JPanel(new BorderLayout());

    // name = new JLabel(" 사용자 이름 ");
    name = new JLabel(" 메세지 입력 ");

    jta = new JTextArea();
    // clientList = new JTextArea(0, 10);
    clientList = new JList();

    jsp = new JScrollPane(jta);
    list = new JScrollPane(clientList);

    jtf = new JTextField("입력하세요.");
    hi = new JTextField("HOST IP 입력");
    pi = new JTextField("PORT 입력");
    localport = new JTextField("원하는 PORT 입력");
    lid = new JTextField("ID를 입력하세요.");
    lpw = new JTextField("PW를 입력하세요.");

    serveropen = new JButton("서버 오픈");
    textin = new JButton("입력");
    clientin = new JButton("서버 접속");
    conf = new JButton("로그인");
    join = new JButton("회원가입");

    addr = InetAddress.getLocalHost();

    // 사용자 해상도 및 창 크기 설정 및 가져오기.
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();

    setSize(500, 500);
    Dimension d = getSize();

    // 각종 버튼 및 텍스트 필드 리스너
    jtf.addActionListener(this);
    hi.addActionListener(this);
    pi.addActionListener(this);
    localport.addActionListener(this);
    lid.addActionListener(this);
    lpw.addActionListener(this);
    conf.addActionListener(this);
    join.addActionListener(this);

    serveropen.addActionListener(this);
    clientin.addActionListener(this);
    textin.addActionListener(this);

    jtf.addFocusListener(this);
    hi.addFocusListener(this);
    pi.addFocusListener(this);
    localport.addFocusListener(this);
    lid.addFocusListener(this);
    lpw.addFocusListener(this);

    // 서버 접속
    h.add(hi);
    h.add(pi);
    h.add(clientin);

    // 서버 생성
    h.add(new JLabel("IP : " + addr.getHostAddress(), (int) CENTER_ALIGNMENT));
    h.add(localport);
    h.add(serveropen);

    // 채팅글창 글 작성 막기
    jta.setEditable(false);

    // 접속자 리스트 width 제한
    clientList.setFixedCellWidth(d.width / 3);

    // 입력 창
    f.add(name, "West");
    f.add(jtf, "Center");
    f.add(textin, "East");

    // 접속자 확인창
    s.add(new JLabel("접속자", (int) CENTER_ALIGNMENT), "North");
    s.add(list, "Center");
    // clientList.setEditable(false);

    // 메인 창
    m.add(jsp, "Center");
    m.add(s, "East");

    // 프레임 설정
    add(h, "North");
    add(m, "Center");
    add(f, "South");

    // 로그인 다이얼로그
    jd = new JDialog();
    jd.setTitle("채팅 로그인");
    jd.add(login);
    jd.setSize(200, 200);
    Dimension dd = jd.getSize();
    jd.setLocation(screenSize.width / 2 - (dd.width / 2), screenSize.height / 2 - (dd.height / 2));
    jd.setVisible(true);

    // 로그인창
    JPanel lm = new JPanel(new GridLayout(4, 1));
    lm.add(lid);
    lm.add(new Label());
    lm.add(lpw);
    lm.add(new Label());

    JPanel bt = new JPanel();
    bt.add(conf);
    bt.add(join);

    login.add(new Label(), "North");
    login.add(new Label(), "West");
    login.add(new Label(), "East");
    login.add(lm, "Center");
    login.add(bt, "South");

    // 창의 위치, 보임, EXIT 단추 활성화.
    setLocation(screenSize.width / 2 - (d.width / 2), screenSize.height / 2 - (d.height / 2));

    setVisible(false);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
Esempio n. 20
0
  Head() {
    setTitle("Head Office");
    setLocation(440, 80);
    f1.setLayout(null);

    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension screenSize = kit.getScreenSize();
    int screenHeight = screenSize.height - 30;
    // int screenWidth = screenSize.width;

    setSize(800, 738);
    // System.out.println(screenHeight);

    setResizable(false);

    //     setSize(800,800);

    lno = new JLabel("Head office Number :");
    lname = new JLabel("              Name :");
    contact = new JLabel("           Contact :");
    address = new JLabel("           Address :");
    state = new JLabel("             State :");
    startdate = new JLabel("        Start Date :");
    howmany = new JLabel(" Total Employee :");

    t1 = new JTextField(10);
    t2 = new JTextField(10);
    t3 = new JTextField(10);
    t4 = new JTextField(10);
    t5 = new JTextField(10);
    t6 = new JTextField(10);
    t7 = new JTextField(10);

    add = new JButton(" Add");
    ok = new JButton("OK");

    ok.addActionListener(this);
    add.addActionListener(this);

    taddress = new JTextArea(15, 20);

    scrpn = new JScrollPane(taddress);

    f1.add(lno);
    f1.add(t1);
    f1.add(lname);
    f1.add(t2);
    f1.add(contact);
    f1.add(t3);
    f1.add(t4);
    f1.add(add);
    f1.add(t5);
    f1.add(address);
    f1.add(scrpn);
    f1.add(state);
    f1.add(t6);
    f1.add(t7);
    f1.add(howmany);
    f1.add(startdate);

    b6 =
        new JButton(
            "Exit"); // , new ImageIcon(ClassLoader.getSystemResource("Images/update.png")));
    b7 = new JButton("View");
    b6.setBounds(180, 370, 100, 30);
    b7.setBounds(50, 370, 100, 30);
    add(b6);
    add(b7);
    b6.addActionListener(this);
    b7.addActionListener(this);

    lno.setBounds(10, 25, 150, 25);
    t1.setBounds(150, 23, 125, 25);

    lname.setBounds(10, 67, 150, 25);
    t2.setBounds(150, 67, 150, 25);

    contact.setBounds(10, 110, 150, 25);
    t3.setBounds(150, 110, 125, 25);

    state.setBounds(10, 153, 150, 25);
    t4.setBounds(150, 153, 125, 25);

    startdate.setBounds(10, 196, 150, 25);
    t5.setBounds(150, 196, 125, 25);

    address.setBounds(10, 239, 150, 25);
    t7.setBounds(150, 239, 250, 25);
    // scrpn.setBounds(150,239,200,50);
    howmany.setBounds(10, 310, 150, 25);
    t6.setBounds(150, 310, 125, 25);

    ok.setBounds(190, 420, 90, 25);
    setSize(445, 500);
    add(f1, BorderLayout.CENTER);
    setVisible(true);
    try {
      Class.forName("com.mysql.jdbc.Driver");
      System.out.println("Driver loaded Succesfull");
      cn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/payroll", "root", "root");
      System.out.println("Connection Succesfull");
      st = cn.createStatement();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, "Error is" + e);
    }
  }
Esempio n. 21
0
  public storiconoleggio() {

    storico = new JFrame("Storico cliente:");
    storico.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    storico.setVisible(true);

    operazioni = new JPanel();
    operazioni.setLayout(new BoxLayout(operazioni, BoxLayout.Y_AXIS));

    sotto = new JPanel();

    gruppo = Box.createVerticalBox();

    indietro = new JButton("Indietro");

    ascoltatore = new listenernolcli();

    Object righe[][] = {
      {"# Noleggio", "ID Bagnino", "# Ombrellone", "Data Noleggio", "Num. Lettini", "ID Cliente"}
    };
    Object colonne[] = {"", "", "", "", "", ""};
    JTable tabella = new JTable(righe, colonne);

    try {
      String url = "jdbc:mysql://127.0.0.1:3306/lido";
      String userid = "root";
      String paswordd = "root";
      con = DriverManager.getConnection(url, userid, paswordd);
      requete = con.createStatement();
      rs =
          requete.executeQuery(
              "SELECT * FROM lido.bagnino_noleggia_ombrellone WHERE cliente_idcliente ="
                  + login.getNomeUtente());
      ResultSetMetaData md = rs.getMetaData();
      int columnCount = md.getColumnCount();

      Vector columns = new Vector(columnCount);

      for (int i = 1; i <= columnCount; i++) columns.add(md.getColumnName(i));
      Vector data = new Vector();
      Vector row;

      while (rs.next()) {
        row = new Vector(columnCount);
        for (int i = 1; i <= columnCount; i++) {
          row.add(rs.getString(i));
        }
        data.add(row);
      }
      table = new JTable(data, columns);
      table.setPreferredScrollableViewportSize(new Dimension(500, 70));
      table.setFillsViewportHeight(true);
      table.setVisible(true);
      table.validate();

    } catch (SQLException sqle) {

      System.out.println(sqle);
      sqle.printStackTrace();
    }

    indietro.addActionListener(ascoltatore);

    operazioni.add(tabella);
    operazioni.add(table);

    sotto.add(indietro);

    gruppo.add(operazioni);
    gruppo.add(sotto);
    storico.add(gruppo);
    storico.pack();
  }
Esempio n. 22
0
  public AuthDialog(final JFrame parent, String title, boolean modal) {
    super(parent, title, modal);

    // Set up close behaviour
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (!okButtonClicked) System.exit(0);
          }
        });

    // Set up OK button behaviour
    JButton okButton = new JButton("OK");
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (getUserName().length() == 0) {
              showMessageDialog(
                  AuthDialog.this, "Please enter a username", "Format Error", ERROR_MESSAGE);
              return;
            }
            if (getDatabasePassword().length() == 0) {
              showMessageDialog(
                  AuthDialog.this, "Please enter a password", "Format Error", ERROR_MESSAGE);
              return;
            }
            okButtonClicked = true;
            setVisible(false);
          }
        });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    // Set up dialog contents
    labelPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 5, 5));
    inputPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 20));

    labelPanel.setLayout(new GridLayout(2, 1));
    labelPanel.add(new JLabel("User Name: "));
    labelPanel.add(new JLabel("Password:"******"ESCAPE"), "exitAction");
    actionMap.put(
        "exitAction",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    // Pack it all
    pack();

    // Center on the screen
    setLocationRelativeTo(null);
  }
Esempio n. 23
0
  public Summary(int patient_id) {
    this.patient_id = patient_id;
    setTitle("Summary");
    setSize(
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth()),
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight()) - 40);
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    head = new JLabel("MEDI_SCAN DIAGNOSTIC LAB SERVICES", SwingConstants.CENTER);
    head.setForeground(Color.WHITE);
    Font f2 = new Font("Papyrus", Font.BOLD, 36);
    head.setFont(f2);
    res = new JLabel("RESULT SUMMARY", SwingConstants.CENTER);
    res.setForeground(Color.WHITE);
    Font f3 = new Font("Papyrus", Font.BOLD, 28);
    res.setFont(f3);
    Font f1 = new Font("Goudy Old Style", Font.BOLD, 16);
    hello = new JLabel("Hello Mr./Miss ");
    hello.setForeground(new Color(54, 34, 174));
    hello.setFont(f1);

    fin = new JLabel("Your Medical Test Is Finished");
    fin.setFont(f1);
    fin.setForeground(new Color(54, 34, 174));
    pname = new JLabel("Patient Name");
    pname.setForeground(new Color(54, 34, 174));
    pname.setFont(f1);
    ldate = new JLabel("Test Date");
    ldate.setForeground(new Color(54, 34, 174));
    ldate.setFont(f1);
    age = new JLabel("Age");
    age.setForeground(new Color(54, 34, 174));
    age.setFont(f1);
    sex = new JLabel("Sex");
    sex.setForeground(new Color(54, 34, 174));
    sex.setFont(f1);
    tname = new JLabel("Test Name");
    tname.setForeground(new Color(54, 34, 174));
    tname.setFont(f1);
    nvalue = new JLabel("Normal Value");
    nvalue.setForeground(new Color(54, 34, 174));
    nvalue.setFont(f1);
    trate = new JLabel("Test Rate");
    trate.setForeground(new Color(54, 34, 174));
    trate.setFont(f1);
    tresult = new JLabel("Test Result");
    tresult.setForeground(new Color(54, 34, 174));
    tresult.setFont(f1);
    tamt = new JLabel("Total Amout");
    tamt.setForeground(new Color(54, 34, 174));
    tamt.setFont(f1);

    exit = new JButton("EXIT");
    exit.setFont(f1);

    pHead = new JPanel(new GridLayout(2, 1));
    pHead.setBackground(new Color(134, 134, 234));
    pCenter = new JPanel(new GridBagLayout());
    pCenter.setBackground(new Color(211, 248, 253));
    pCom = new JPanel(new BorderLayout());
    pCom.setBackground(new Color(211, 248, 253));
    pSouth = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    pSouth.setBackground(new Color(211, 248, 253));

    // Adding Icon on top-left.
    ImageIcon img = new ImageIcon("pics/logo.jpg");
    this.setIconImage(img.getImage());

    try {
      Connection con = JDBCConnection.getConnection();
      PreparedStatement pstmt =
          con.prepareStatement(
              "Select first_name,last_name,age,sex,test_id,tdate from patientreg where patient_id=?");
      pstmt.setInt(1, this.patient_id);
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        first_name = rs.getString("first_name");
        lname = rs.getString("last_name");
        name = new JLabel(first_name + " " + lname);
        name1 = new JLabel(first_name + " " + lname);
        p_age = rs.getInt("age");
        pAge = new JLabel(p_age + "");
        p_sex = rs.getString("sex");
        psex = new JLabel(p_sex);
        t_id = rs.getInt("test_id");
        t_date = rs.getString("tdate");
        date1 = new JLabel(t_date);
      }
    } catch (SQLException s) {
      s.printStackTrace();
    }

    try {
      Connection con = JDBCConnection.getConnection();
      PreparedStatement pstmt =
          con.prepareStatement("Select test_result from reportbydoctor where patient_id=?");
      pstmt.setInt(1, this.patient_id);
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {

        te_res = rs.getString("test_result");
        result = new JLabel(te_res);
      }
    } catch (SQLException s) {
      s.printStackTrace();
    }

    try {
      Connection con = JDBCConnection.getConnection();
      PreparedStatement pstmt =
          con.prepareStatement("select normal_val,rate,test_name from addtest where test_id=?");
      pstmt.setInt(1, t_id);
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        n_value = rs.getInt("normal_val");
        normal_value1 = new JLabel(n_value + "");
        te_rate = rs.getInt("rate");
        rate1 = new JLabel(te_rate + "");
        rate2 = new JLabel(te_rate + "");
        te_name = rs.getString("test_name");
        testname = new JLabel(te_name);
      }
    } catch (SQLException a) {
      a.printStackTrace();
    }

    content = getContentPane();

    // for label hello
    GridBagConstraints gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 1;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 50, 20, 0);
    pCenter.add(hello, gc);

    // for label name1
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 1;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 0);
    pCenter.add(name1, gc);

    // for label fin
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 3;
    gc.gridwidth = 2;
    gc.gridy = 1;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(fin, gc);

    // for label pname
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 2;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(pname, gc);

    // for label name
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 2;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(name, gc);

    // for label ldate
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 3;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(ldate, gc);

    // for label date1
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 3;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(date1, gc);

    // for label age
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 4;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(age, gc);

    // for label pAge
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 4;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(pAge, gc);

    // for label sex
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 5;
    gc.ipadx = 125;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(sex, gc);

    // for label psex
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 5;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);

    pCenter.add(psex, gc);

    // for label tname
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 6;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(tname, gc);

    // for label nvalue
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 6;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(nvalue, gc);

    // for label trate
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 3;
    gc.gridwidth = 1;
    gc.gridy = 6;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(trate, gc);

    // for label tresult
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 4;
    gc.gridwidth = 1;
    gc.gridy = 6;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(tresult, gc);

    // for label testname
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 7;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(testname, gc);

    // for label normal_value1
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 7;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(normal_value1, gc);

    // for label rate1
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 3;
    gc.gridwidth = 1;
    gc.gridy = 7;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(rate1, gc);

    // for label result
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 4;
    gc.gridwidth = 1;
    gc.gridy = 7;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(result, gc);

    // for label tamt
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 3;
    gc.gridwidth = 1;
    gc.gridy = 8;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(tamt, gc);

    // for label rate2
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 4;
    gc.gridwidth = 1;
    gc.gridy = 8;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(rate2, gc);

    exit.addActionListener(this);
    pSouth.add(exit);
    content.add(pSouth, BorderLayout.SOUTH);

    pHead.add(head);
    pHead.add(res);

    content.add(pHead, BorderLayout.NORTH);
    content.add(pCenter, BorderLayout.CENTER);
    setVisible(true);
  }
Esempio n. 24
0
  /** Initialize the contents of the frame. */
  private void initialize() {

    JPanel mainPanel = new JPanel();

    JButton book = new JButton("Book");
    mainPanel.add(book);
    book.setPreferredSize(new Dimension(200, 80));

    JTextField enterFlightNum = new JTextField("Enter Flight Number");
    enterFlightNum.setColumns(10);
    enterFlightNum.setBounds(227, 251, 286, 42);
    mainPanel.add(enterFlightNum);

    JButton mainMenu = new JButton("Main Menu");
    mainPanel.add(mainMenu);
    mainMenu.setPreferredSize(new Dimension(200, 80));
    mainMenu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            fFrame.setVisible(false);
            new MainUI(c1);
          }
        });

    book.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            try {
              c1.bookFlight(Integer.parseInt(enterFlightNum.getText()));
              ;
            } catch (Exception ex) {

              ex.printStackTrace();
            }
          }
        });

    JPanel mainPanel2 = new JPanel();
    JLabel listFlights = new JLabel();
    mainPanel2.add(listFlights);

    Connection connection;
    String labelText = "<html>";
    try {
      Class.forName("com.mysql.jdbc.Driver");
      System.out.println("Driver loaded");

      connection = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "CIS3270", "Cis3270");

      System.out.println("Connection complete");

      Statement statement;

      statement = connection.createStatement();

      String queryString = "select * from flight";

      ResultSet rs = statement.executeQuery(queryString);

      while (rs.next()) {

        labelText =
            labelText
                + rs.getString(1)
                + " "
                + rs.getString(3)
                + " "
                + rs.getString(4)
                + " "
                + rs.getString(5)
                + " "
                + rs.getString(6)
                + "<br>";
      }

    } catch (Exception e) {

    }

    listFlights.setText(labelText);
    System.out.println(labelText);

    JPanel mainCombine = new JPanel();
    mainCombine.add(mainPanel, BorderLayout.NORTH);
    mainCombine.add(mainPanel2, BorderLayout.SOUTH);

    fFrame = new JFrame();
    fFrame.setSize(1000, 800);
    fFrame.add(mainCombine);
    fFrame.setVisible(true);
    fFrame.setResizable(false);
    fFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    fFrame.getContentPane().setLayout(null);
  }
Esempio n. 25
0
  public TableModelDemo() {

    try {
      // Load the JDBC driver
      Class.forName("com.mysql.jdbc.Driver");
      Class.forName("oracle.jdbc.driver.OracleDriver");
      System.out.println("Driver loaded");

      // Create a row set
      rowSet = new CachedRowSetImpl();

      // Set RowSet properties
      //      rowSet.setUrl("jdbc:mysql://localhost/javabook");
      rowSet.setUrl("jdbc:oracle:thin:@liang.armstrong.edu:1521:orcl");
      rowSet.setUsername("scott");
      rowSet.setPassword("tiger");

      rowSet.setCommand("select * from StateCapital");

      rowSet.setConcurrency(ResultSet.CONCUR_UPDATABLE);
      rowSet.execute();
      tableModel.setRowSet(rowSet);
      rowSet.addRowSetListener(tableModel);
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayout(2, 2));
    panel1.add(jbtAddRow);
    panel1.add(jbtAddColumn);
    panel1.add(jbtDeleteRow);
    panel1.add(jbtDeleteColumn);

    JPanel panel2 = new JPanel();
    panel2.add(jbtSave);
    panel2.add(jbtClear);
    panel2.add(jbtRestore);

    JPanel panel3 = new JPanel();
    panel3.setLayout(new BorderLayout(5, 0));
    panel3.add(new JLabel("Selection Mode"), BorderLayout.WEST);
    panel3.add(jcboSelectionMode, BorderLayout.CENTER);

    JPanel panel4 = new JPanel();
    panel4.setLayout(new FlowLayout(FlowLayout.LEFT));
    panel4.add(jchkRowSelectionAllowed);
    panel4.add(jchkColumnSelectionAllowed);

    JPanel panel5 = new JPanel();
    panel5.setLayout(new GridLayout(2, 1));
    panel5.add(panel3);
    panel5.add(panel4);

    JPanel panel6 = new JPanel();
    panel6.setLayout(new BorderLayout());
    panel6.add(panel1, BorderLayout.SOUTH);
    panel6.add(panel2, BorderLayout.CENTER);

    add(panel5, BorderLayout.NORTH);
    add(new JScrollPane(jTable1), BorderLayout.CENTER);
    add(panel6, BorderLayout.SOUTH);

    // Initialize table selection mode
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    jbtAddRow.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              rowSet.absolute(2);
              rowSet.moveToInsertRow();
              rowSet.updateString("state", "Georia");
              rowSet.updateString("capital", "Atlanta");
              rowSet.insertRow();
              ((CachedRowSetImpl) rowSet).acceptChanges();
              rowSet.moveToCurrentRow();
            } catch (Exception ex) {
              ex.printStackTrace();
            }

            //        if (jTable1.getSelectedRow() >= 0)
            //          tableModel.insertRow(jTable1.getSelectedRow(),
            //            new java.util.Vector());
            //        else
            //          tableModel.addRow(new java.util.Vector());
          }
        });

    jbtAddColumn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            //        String name = JOptionPane.showInputDialog("New Column Name");
            //        tableModel.addColumn(name, new java.util.Vector());
          }
        });

    jbtDeleteRow.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (jTable1.getSelectedRow() >= 0) {
              try {
                rowSet.absolute(jTable1.getSelectedRow() + 1);
                rowSet.deleteRow();
                ((CachedRowSetImpl) rowSet).acceptChanges();
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
          }
        });

    jbtDeleteColumn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (jTable1.getSelectedColumn() >= 0) {
              TableColumnModel columnModel = jTable1.getColumnModel();
              TableColumn tableColumn = columnModel.getColumn(jTable1.getSelectedColumn());
              columnModel.removeColumn(tableColumn);
            }
          }
        });

    jbtSave.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              ObjectOutputStream out =
                  new ObjectOutputStream(new FileOutputStream("tablemodel.dat"));
              //          out.writeObject(tableModel.getDataVector());
              out.writeObject(getColumnNames());
              out.close();
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    jbtClear.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            //        tableModel.setRowCount(0);
          }
        });

    jbtRestore.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              ObjectInputStream in = new ObjectInputStream(new FileInputStream("tablemodel.dat"));
              Vector rowData = (Vector) in.readObject();
              Vector columnNames = (Vector) in.readObject();
              //          tableModel.setDataVector(rowData, columnNames);
              in.close();
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    jchkRowSelectionAllowed.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            jTable1.setRowSelectionAllowed(jchkRowSelectionAllowed.isSelected());
          }
        });

    jchkColumnSelectionAllowed.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            jTable1.setColumnSelectionAllowed(jchkColumnSelectionAllowed.isSelected());
          }
        });

    jcboSelectionMode.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String selectedItem = (String) jcboSelectionMode.getSelectedItem();

            if (selectedItem.equals("SINGLE_SELECTION"))
              jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            else if (selectedItem.equals("SINGLE_INTERVAL_SELECTION"))
              jTable1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            else if (selectedItem.equals("MULTIPLE_INTERVAL_SELECTION"))
              jTable1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
          }
        });
  }
Esempio n. 26
0
  Usermaster() {
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    x = dim.width;
    y = dim.height;
    setSize(x, y);
    setUndecorated(true);

    Container c = getContentPane();

    center =
        new JPanel() {
          public void paintComponent(Graphics g) {
            Toolkit kit = Toolkit.getDefaultToolkit();
            Image img = kit.getImage("Image/user.jpg");
            MediaTracker t = new MediaTracker(this);
            t.addImage(img, 0);
            while (true) {
              try {
                t.waitForAll();
                break;
              } catch (Exception ee) {
              }
            }
            g.drawImage(img, 0, 0, x, y, null);
          }
        };

    c.add(center);
    center.setLayout(null);

    titleLb =
        new JLabel(
            "<html><body ><font size='5'><b><i>&nbsp;&nbsp; User Name &nbsp;&nbsp;</b></i></font></body></html>");
    titleLb.setForeground(new Color(10, 110, 255));
    titleLb.setBounds(x / 2 + 50, x / 4, 150, 50);
    center.add(titleLb);

    output =
        new JLabel(
            "<html><body ><font size='5'><b><i>&nbsp;&nbsp; OUTPUT &nbsp;&nbsp;</b></i></font></body></html>");
    output.setForeground(Color.white);
    output.setBounds(x / 2 - 250, x / 6, 150, 50);
    center.add(output);

    login = new JButton(new ImageIcon("Image/logBut.gif"));
    login.setBorder(BorderFactory.createRaisedBevelBorder());
    login.setBounds(x / 2 + 100, x / 2 - 70, 100, 100);
    login.setBackground(Color.white);

    pass = new JPasswordField();
    pass.setToolTipText("Enter The Password To Payroll System");
    login.requestFocus();
    pass.setBorder(BorderFactory.createRaisedBevelBorder());
    pass.setForeground(new Color(10, 110, 255));
    pass.setFont(new Font("Arial", Font.BOLD, 22));
    pass.setCaretColor(Color.red);
    pass.setBounds(x / 2 + 50, x / 3, 200, 35);
    center.add(pass);
    center.add(login);

    pass.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            output.setText(
                "<html><body ><font size='5'><b><i>&nbsp;&nbsp; OUTPUT &nbsp;&nbsp;</b></i></font></body></html>");
            output.setForeground(Color.white);
          }
        });

    try {
      clsConnection connect = new clsConnection();
      conn = connect.setConnection(conn, "", "");
    } catch (Exception e) {
    }

    login.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              st = conn.createStatement();
              rs = st.executeQuery("select * from img");
              while (rs.next()) {
                if (pass.getText().equals(rs.getString(3))) {
                  setVisible(false);
                  URL url = closeSystem.class.getResource("spacemusic.au");
                  click = Applet.newAudioClip(url);
                  click.play();
                  paro.setVisible(true);
                } else {
                  pass.setText("");
                  pass.requestFocus();
                  output.setText("Fell");
                  output.setFont(new Font("Arial", Font.BOLD, 36));
                  output.setForeground(Color.red);
                }
              }
            } catch (Exception er) {
              System.out.println("Sorry\n" + er);
            }
          }
        });
  }
Esempio n. 27
0
  public NewTaskFrame() throws SQLException {

    this.setModal(true);
    this.setTitle("Create Task"); // title of frame
    this.setSize(400, 350);
    this.setLayout(new BorderLayout()); // layout of frame

    JLabel task_id = new JLabel("ID:");
    JLabel task_name = new JLabel("Name:");
    JLabel task_desc = new JLabel("Description:");

    JLabel priority = new JLabel("Level of Priority:");
    JLabel duedate = new JLabel("Due Date (yyyy-mm-dd)");
    JLabel numberofdays = new JLabel("Number of days required:");
    JLabel skills_required = new JLabel("Skills Required:");

    Object[] id_possibilities = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
    StringBuffer generated_name = new StringBuffer("t");

    for (int i = 0; i < 6; ++i) {
      generated_name.append(
          id_possibilities[new java.util.Random().nextInt(id_possibilities.length)]);
    }

    task_idfield = new JTextField(generated_name.toString());
    taskname_field = new JTextField();
    taskdesc_field = new JTextArea();

    priority_checkbox = new JCheckBox("High", false);
    numberofdays_field = new JTextField();

    format = new SimpleDateFormat("dd-MM-yyyy"); // set format
    duedate_field = new JFormattedTextField(format);

    // set the duedatefield to tomorrow (since minimum task length = 1)
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.setTime(new Date()); // get current date
    cal.add(Calendar.DAY_OF_MONTH, 1); // add 1 to current date
    Date date = cal.getTime(); // get this date
    duedate_field.setValue(date); // set this date to the field

    // panel to hold labels and text fields
    JPanel labeltextpanel = new JPanel();
    labeltextpanel.setLayout(new GridLayout(7, 2));
    labeltextpanel.add(task_id);
    labeltextpanel.add(task_idfield);
    labeltextpanel.add(task_name);
    labeltextpanel.add(taskname_field);
    labeltextpanel.add(task_desc);
    labeltextpanel.add(taskdesc_field);
    labeltextpanel.add(priority);
    labeltextpanel.add(priority_checkbox);
    labeltextpanel.add(numberofdays);
    labeltextpanel.add(numberofdays_field);
    labeltextpanel.add(duedate);
    labeltextpanel.add(duedate_field);
    labeltextpanel.add(skills_required);

    this.getSkills();

    // main panel for frame including its layout
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(labeltextpanel, BorderLayout.CENTER);

    // buttons
    clear_button = new JButton("Clear");
    submit_button = new JButton("Submit");

    // add listeners to buttons
    clear_button.addActionListener(this);
    submit_button.addActionListener(this);

    // create panel for buttons and add buttons
    JPanel buttonpanel = new JPanel();
    buttonpanel.setLayout(new FlowLayout());
    buttonpanel.add(clear_button);
    buttonpanel.add(submit_button);

    JPanel checkbox_panel = new JPanel();
    checkbox_panel.setLayout(new FlowLayout());

    for (int i = 0; i < skill_list.size(); i++) {
      checkbox_panel.add(skill_list.get(i)); // make this panel flowlayout
    }

    scrollpane = new JScrollPane(checkbox_panel);
    scrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(mainPanel, BorderLayout.CENTER);
    panel.add(scrollpane, BorderLayout.SOUTH);
    // add the main panel to main frame

    add(panel, BorderLayout.CENTER);
    add(buttonpanel, BorderLayout.SOUTH);

    this.setVisible(true);
  }
Esempio n. 28
0
  public NewUser() {
    super("Adding New User");
    label1 = new JLabel("Name");
    label2 = new JLabel("Category");
    username = new JLabel("Username");
    password = new JLabel("Password");
    confirm = new JLabel("Re-enter Password");
    pass1 = new JPasswordField();
    pass2 = new JPasswordField();
    txtusername = new JTextField();
    name = new JTextField();
    combo1 = new JComboBox();
    button1 = new JButton("Ok", new ImageIcon("Icon/i16x16/ok.png"));
    button2 = new JButton("Cancel", new ImageIcon("Icon/i16x16/exit.png"));

    panel1 = new JPanel(new GridLayout(6, 2));
    panel1.add(label1);
    panel1.add(name);
    panel1.add(label2);
    panel1.add(combo1);
    panel1.add(username);
    panel1.add(txtusername);
    panel1.add(password);
    panel1.add(pass1);
    panel1.add(confirm);
    panel1.add(pass2);
    panel1.add(button1);
    panel1.add(button2);
    combo1.addItem("Manager");
    combo1.addItem("Booking Clerk");
    combo1.addItem("Supervisor");
    panel2 = new JPanel();
    panel2.add(panel1);
    getContentPane().add(panel2);
    setSize(350, 195);
    setVisible(true);
    setLocation((screen.width - 500) / 2, ((screen.height - 350) / 2));
    setResizable(false);
    name.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            if (!(Character.isLetter(c)
                || (c == KeyEvent.VK_BACK_SPACE)
                || (c == KeyEvent.VK_SPACE)
                || (c == KeyEvent.VK_DELETE))) {

              getToolkit().beep();
              JOptionPane.showMessageDialog(
                  null, "Invalid Character", "ERROR", JOptionPane.DEFAULT_OPTION);
              e.consume();
            }
          }
        });
    txtusername.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            if (!(Character.isLetter(c)
                || (c == KeyEvent.VK_BACK_SPACE)
                || (c == KeyEvent.VK_SPACE)
                || (c == KeyEvent.VK_DELETE))) {

              getToolkit().beep();
              JOptionPane.showMessageDialog(
                  null, "Invalid Character", "ERROR", JOptionPane.DEFAULT_OPTION);
              e.consume();
            }
          }
        });
    button1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {

            if (name.getText() == null || name.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter name", "ERROR", JOptionPane.DEFAULT_OPTION);
              name.requestFocus();
              return;
            }
            if (txtusername.getText() == null || txtusername.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter username", "ERROR", JOptionPane.DEFAULT_OPTION);
              txtusername.requestFocus();
              return;
            }
            if (pass1.getText() == null || pass1.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter password", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass1.requestFocus();
              return;
            }
            if (pass2.getText() == null || pass2.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Confirm your password", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass2.requestFocus();
              return;
            }
            if (!pass1.getText().equals(pass2.getText())) {
              JOptionPane.showMessageDialog(
                  null, "passwords do not match.", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass2.requestFocus();
              return;
            }
            try {
              Statement statement = Connect.getConnection().createStatement();
              {
                String temp =
                    "INSERT INTO users (Name,Category,username, password) VALUES ('"
                        + name.getText()
                        + "', '"
                        + combo1.getSelectedItem()
                        + "', '"
                        + txtusername.getText()
                        + "', '"
                        + pass1.getText()
                        + "')";

                int result = statement.executeUpdate(temp);
                JOptionPane.showMessageDialog(
                    null, "User is succesfully added", "SUCCESS", JOptionPane.DEFAULT_OPTION);
                dispose();
              }

            } catch (Exception in) {
              in.printStackTrace();
            }
          }
        });
    button2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
  }
  public TabelProduk() {
    // tfFilter = new JTextField(30);
    // bFilter = new JButton("filter");
    bHapus = new JButton("hapus");

    panelUtama = new JPanel(new BorderLayout());
    // panelFilter = new JPanel();
    panelButton = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    // set jenis
    setJenis();

    // panel utama
    setDataTabel();
    srcTabel = new JScrollPane(tabel);

    // panelUtama.add(panelFilter,"North");
    panelUtama.add(srcTabel, "Center");
    panelUtama.add(panelButton, "South");

    // filter
    // panelFilter.add(new JLabel("filter : "));
    // panelFilter.add(tfFilter);
    // panelFilter.add(bFilter);

    // untuk button
    panelButton.add(bHapus);

    class HapusListener implements ListSelectionListener, ActionListener {
      private int idProduk;

      public void valueChanged(ListSelectionEvent e) {
        int baris = tabel.getSelectedRow();

        if (baris > -1) {
          Produk p = dataProduk.get(baris);
          idProduk = p.getIdProduk();
        }
      }

      public void actionPerformed(ActionEvent ev) {
        try {
          // stok
          String query = "DELETE FROM stok_produk WHERE id_produk=" + idProduk;
          int hasil1 = stm.executeUpdate(query);

          // pemasukkan
          query = "DELETE FROM pemasukan WHERE id_produk=" + idProduk;
          int hasil2 = stm.executeUpdate(query);

          // pengeluaran
          query = "DELETE FROM pengeluaran WHERE id_produk=" + idProduk;
          int hasil3 = stm.executeUpdate(query);

          // produk
          query = "DELETE FROM produk WHERE id_produk=" + idProduk;
          int hasil4 = stm.executeUpdate(query);

          if (hasil1 == 1 || hasil2 == 1 || hasil3 == 1 && hasil4 == 1) {
            setDataTabel();
            JOptionPane.showMessageDialog(null, "berhasil hapus");
          } else {
            JOptionPane.showMessageDialog(null, "gagal");
          }
        } catch (SQLException SQLerr) {
          SQLerr.printStackTrace();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    HapusListener hl = new HapusListener();
    tabel.getSelectionModel().addListSelectionListener(hl);
    bHapus.addActionListener(hl);
  }
  public patientAdd(String s) {
    super(s);
    image =
        new JLabel() {
          public void paint(Graphics g) {
            ImageIcon ic = new ImageIcon(str);
            Image img = ic.getImage();
            g.drawImage(img, 0, 0, 150, 150, this);
          }
        };

    image.setBounds(670, 270, 300, 300);
    bu = new JButton("UPLOAD");
    bu.setBounds(700, 230, 100, 20);
    bu.addActionListener(this);
    //	q.add(bu);

    ldt = new JLabel("Date");
    lpid = new JLabel("Patient ID");
    lpnm = new JLabel("Patient Name");
    lgen = new JLabel("Gender");
    lbg = new JLabel("Blood Group");
    lage = new JLabel("Age");
    lwt = new JLabel("Weight                                          Kg");
    ladd = new JLabel("Address");
    lcno = new JLabel("Cont. no.");
    ldnm = new JLabel("Doctor Name            Dr.");
    lsym = new JLabel("Symptoms");
    ldig = new JLabel("Diagnosis");
    lfee = new JLabel("Fee                            Rs.");
    cbg = new CheckboxGroup();
    cm = new Checkbox("Male", cbg, false);
    cm.addItemListener(this);
    cf = new Checkbox("Female", cbg, false);
    cf.setState(true);
    cf.addItemListener(this);
    tdt = new JTextField(15);
    tpid = new JTextField(6);
    tpid.addFocusListener(this);
    tpfnm = new JTextField("first");
    tpmnm = new JTextField("middle");
    tplnm = new JTextField("last");
    tage = new JTextField(4);
    tage.addFocusListener(this);
    tbg = new JTextField(6);
    twt = new JTextField(5);
    tadd = new TextArea(patient.addr);
    tcno = new JTextField(20);
    tdnm = new JTextField(20);
    tsym = new TextArea();

    tdig = new JTextField(20);
    tfee = new JTextField(6);
    tfee.addFocusListener(this);
    ba = new JButton("ADD");
    ba.addActionListener(this);
    bm = new JButton("CANCEL");
    bm.addActionListener(this);
    bd = new JButton("DELETE");
    bd.addActionListener(this);
    bl = new JButton("DISPLAY");
    bl.addActionListener(this);
    bs = new JButton("SEARCH");
    bs.addActionListener(this);
    JPanel p = new JPanel();
    p.add(ba);
    p.add(bm);
    //	p.add(bd);
    //	p.add(bl);
    //	p.add(bs);
    add(p, BorderLayout.SOUTH);
    q = new JPanel();
    q.setLayout(null);
    ldt.setBounds(1015, 20, 60, 20);
    q.add(ldt);
    tdt.setBounds(1060, 20, 170, 20);
    q.add(tdt);
    lpid.setBounds(70, 60, 80, 20);
    q.add(lpid);
    tpid.setBounds(200, 60, 60, 20);
    q.add(tpid);
    lpnm.setBounds(70, 100, 80, 20);
    q.add(lpnm);
    tpfnm.setBounds(200, 100, 100, 20);
    q.add(tpfnm);
    tpmnm.setBounds(320, 100, 100, 20);
    q.add(tpmnm);
    tplnm.setBounds(440, 100, 100, 20);
    q.add(tplnm);
    lgen.setBounds(70, 140, 60, 20);
    q.add(lgen);
    lbg.setBounds(370, 140, 80, 20);
    q.add(lbg);
    tbg.setBounds(470, 140, 60, 20);
    q.add(tbg);
    cm.setBounds(200, 140, 60, 20);
    cf.setBounds(280, 140, 60, 20);
    lage.setBounds(70, 180, 40, 20);
    q.add(lage);
    tage.setBounds(200, 180, 50, 20);
    q.add(tage);
    lwt.setBounds(370, 180, 200, 20);
    q.add(lwt);
    twt.setBounds(470, 180, 60, 20);
    q.add(twt);
    ladd.setBounds(70, 220, 60, 20);
    q.add(ladd);
    tadd.setBounds(200, 220, 350, 50);
    q.add(tadd);
    lcno.setBounds(70, 310, 60, 20);
    q.add(lcno);
    tcno.setBounds(200, 310, 120, 20);
    q.add(tcno);
    ldnm.setBounds(70, 350, 200, 20);
    q.add(ldnm);
    tdnm.setBounds(200, 350, 150, 20);
    q.add(tdnm);
    lsym.setBounds(70, 390, 100, 20);
    q.add(lsym);
    tsym.setBounds(200, 390, 300, 70);
    q.add(tsym);
    ldig.setBounds(70, 480, 60, 20);
    q.add(ldig);
    tdig.setBounds(200, 480, 100, 20);
    q.add(tdig);
    lfee.setBounds(70, 520, 200, 20);
    q.add(lfee);
    tfee.setBounds(200, 520, 40, 20);
    q.add(tfee);
    q.add(cm);
    q.add(cf);
    q.add(image);
    q.add(bu);
    add(q, BorderLayout.CENTER);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            try {
              patient.con.close();
              System.exit(0);
            } catch (Exception e8) {
            }
          }
        });
    System.out.println(tadd.getText());
    setSize(1330, 740);
    setVisible(true);
  }