コード例 #1
0
ファイル: M.java プロジェクト: saraswatendra/Login-Page
  Jf() {

    j.setBounds(500, 40, 500, 500);
    j.setVisible(true);
    j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    j.setLayout(null);
    ImageIcon image = new ImageIcon("im1.jpg");
    JLabel l = new JLabel(image);
    int m = image.getIconWidth();
    int m1 = image.getIconHeight();
    j.setResizable(false); // frame resize nahi hoga	
    l.setBounds(0, 0, m, m1);
    j.add(l);
    l.add(linfo);
    l.add(lid);
    l.add(fid);
    l.add(lpass);
    l.add(fpass);
    fpass.setEchoChar('*');

    l.add(blogin);
    l.add(bnewaccount);
    l.add(bforget);

    ImageIcon image1 = new ImageIcon("logo1.png");
    JLabel limage = new JLabel(image1);
    l.add(limage);
    limage.setBounds(10, 50, 190, 130);

    Font f = new Font("ALGERIAN", Font.BOLD, 20);
    linfo.setFont(f);
    linfo.setBounds(40, 10, 420, 30);
    lid.setBounds(210, 50, 70, 30);
    fid.setBounds(290, 50, 150, 30);
    lpass.setBounds(210, 90, 70, 30);
    fpass.setBounds(290, 90, 150, 30);
    blogin.setBounds(210, 130, 100, 50);
    bnewaccount.setBounds(320, 130, 160, 20);
    bforget.setBounds(320, 160, 160, 20);
    blogin.setBackground(Color.green);
    bnewaccount.setBackground(Color.cyan);
    bforget.setBackground(Color.pink);

    blogin.addActionListener(new Login());
    bnewaccount.addActionListener(new Account());
    bforget.addActionListener(new Forget());
  }
コード例 #2
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);
  }
コード例 #3
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.getContentPane().setBackground(new Color(153, 50, 204));
    frame.setBounds(100, 100, 725, 547);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JLabel lblNewLabel = new JLabel("Username");
    lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 18));
    lblNewLabel.setBounds(119, 113, 146, 36);
    frame.getContentPane().add(lblNewLabel);

    textField = new JTextField();
    textField.setBounds(355, 122, 153, 22);
    frame.getContentPane().add(textField);
    textField.setColumns(10);

    JLabel lblNewLabel_1 = new JLabel("Password");
    lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 18));
    lblNewLabel_1.setBounds(119, 213, 87, 22);
    frame.getContentPane().add(lblNewLabel_1);

    JButton btnNewButton = new JButton("Back");
    btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 22));
    btnNewButton.setBounds(124, 313, 121, 36);
    frame.getContentPane().add(btnNewButton);

    JButton btnNewButton_1 = new JButton("Login");
    btnNewButton_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            try {
              String query = "select * from logindetails where UserName=? and Password=?";
              PreparedStatement pst = connect.prepareStatement(query);
              pst.setString(1, textField.getText());
              pst.setString(2, passwordField.getText());
              ResultSet rs = pst.executeQuery();
              if (rs.next()) {
                // JOptionPane.showMessageDialog(null, "connection successfull");
                ah.setVisible(true);
                frame.dispose();
              } else {
                JOptionPane.showMessageDialog(
                    null, "user credentials are wrong.Try again with correct credentials");
              }
            } catch (Exception e) {
              JOptionPane.showMessageDialog(null, e);
            }
          }
        });
    btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 22));
    btnNewButton_1.setBounds(424, 314, 97, 35);
    frame.getContentPane().add(btnNewButton_1);

    passwordField = new JPasswordField();
    passwordField.setBounds(355, 215, 166, 22);
    frame.getContentPane().add(passwordField);

    JLabel lblNewLabel_2 = new JLabel("Administrator Login");
    lblNewLabel_2.setForeground(new Color(128, 128, 128));
    lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 28));
    lblNewLabel_2.setBounds(199, 48, 309, 34);
    frame.getContentPane().add(lblNewLabel_2);
  }
コード例 #4
0
  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);
  }
コード例 #5
0
ファイル: Head.java プロジェクト: thite-amol/payroll
  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);
    }
  }
コード例 #6
0
  DoctorInfomodify() {
    super("Doctor Information");

    setSize(1200, 750);
    setLocationRelativeTo(null);
    setLayout(null);

    lmain = new JLabel("Doctor Information");
    lmain.setBounds(440, 35, 107, 15);
    add(lmain);

    ldi = new JLabel("Doctor Information");
    ldi.setBounds(40, 70, 120, 15);
    add(ldi);

    lname = new JLabel("Name :");
    lname.setBounds(104, 97, 70, 25);
    add(lname);

    tfname = new JTextField(30);
    tfname.setBounds(270, 97, 250, 20);
    add(tfname);

    ladd = new JLabel("Address :");
    ladd.setBounds(104, 138, 70, 15);
    add(ladd);

    taadd = new TextArea();
    taadd.setBounds(270, 138, 250, 100);
    add(taadd);

    ltel = new JLabel("Contact :");
    ltel.setBounds(575, 138, 50, 25);
    add(ltel);

    ldid = new JLabel("Doctor ID:");
    ldid.setBounds(570, 97, 70, 25);
    add(ldid);

    tfdid = new JTextField(30);
    tfdid.setBounds(643, 97, 50, 20);
    add(tfdid);

    tftel = new JTextField(30);
    tftel.setBounds(640, 138, 200, 20);
    add(tftel);
    settings.Numvalidator(tftel);

    ldspec = new JLabel("Specialization :");
    ldspec.setBounds(104, 310, 100, 25);
    add(ldspec);

    taspecial = new TextArea();
    taspecial.setBounds(270, 310, 250, 100);
    add(taspecial);

    lwork = new JLabel("Working hours :");
    lwork.setBounds(570, 310, 100, 15);
    add(lwork);

    lworkfrom = new JLabel("From :");
    lworkfrom.setBounds(670, 305, 37, 25);
    add(lworkfrom);

    tfworkf = new JTextField(30);
    tfworkf.setBounds(710, 310, 30, 20);
    add(tfworkf);
    settings.Numvalidator(tfworkf);

    lworkto = new JLabel("to :");
    lworkto.setBounds(747, 305, 20, 25);
    add(lworkto);

    tfworkt = new JTextField(30);
    tfworkt.setBounds(775, 310, 30, 20);
    add(tfworkt);
    settings.Numvalidator(tfworkt);

    bsub = new JButton("SEARCH", new ImageIcon("images/search.png"));
    bsub.setBounds(250, 643, 110, 30);
    add(bsub);

    bclr = new JButton("CLEAR", new ImageIcon("images/LOGGOFF.PNG"));
    bclr.setBounds(390, 643, 100, 30);
    add(bclr);

    bmod = new JButton("MODIFY", new ImageIcon("images/modify.png"));
    bmod.setBounds(530, 643, 100, 30);
    add(bmod);

    bback = new JButton("BACK", new ImageIcon("images/restore.png"));
    bback.setBounds(700, 643, 100, 30);
    add(bback);

    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      cn = DriverManager.getConnection("Jdbc:Odbc:doc");
    } catch (Exception e) {
      System.out.println(e);
    }

    bclr.addActionListener(new clear());
    bsub.addActionListener(new submit());
    bmod.addActionListener(new modify());
    bback.addActionListener(new back());

    setVisible(true);
  }
コード例 #7
0
  /** Create the frame. */
  public SotrudnikDialog() {
    setTitle(
        "\u041D\u043E\u0432\u044B\u0439 \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A");
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setBounds(100, 100, 450, 330);
    contentPane = new JPanel();
    contentPane.setBackground(new Color(255, 204, 255));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel label_familiya = new JLabel("\u0424\u0430\u043C\u0438\u043B\u0438\u044F");
    label_familiya.setBounds(10, 37, 110, 14);
    contentPane.add(label_familiya);

    JLabel label_imya = new JLabel("\u0418\u043C\u044F");
    label_imya.setBounds(10, 62, 110, 14);
    contentPane.add(label_imya);

    JLabel label_otchestvo = new JLabel("\u041E\u0442\u0447\u0435\u0441\u0442\u0432\u043E");
    label_otchestvo.setBounds(10, 87, 110, 14);
    contentPane.add(label_otchestvo);

    textField_otchestvo = new JTextField();
    textField_otchestvo.setBounds(167, 84, 186, 20);
    contentPane.add(textField_otchestvo);
    textField_otchestvo.setColumns(10);

    textField_imya = new JTextField();
    textField_imya.setBounds(167, 58, 186, 20);
    contentPane.add(textField_imya);
    textField_imya.setColumns(10);

    textField_familiya = new JTextField();
    textField_familiya.setBounds(167, 33, 186, 20);
    contentPane.add(textField_familiya);
    textField_familiya.setColumns(10);

    JLabel label_data_priema =
        new JLabel(
            "\u0414\u0430\u0442\u0430 \u043F\u0440\u0438\u0435\u043C\u0430 \u043D\u0430 \u0440\u0430\u0431\u043E\u0442\u0443");
    label_data_priema.setBounds(10, 112, 147, 14);
    contentPane.add(label_data_priema);

    JLabel label_phone = new JLabel("\u0422\u0435\u043B\u0435\u0444\u043E\u043D");
    label_phone.setBounds(10, 137, 134, 14);
    contentPane.add(label_phone);

    JLabel label_doljnost = new JLabel("\u0414\u043E\u043B\u0436\u043D\u043E\u0441\u0442\u044C");
    label_doljnost.setBounds(10, 162, 140, 14);
    contentPane.add(label_doljnost);

    JLabel label_kvalification =
        new JLabel("\u041A\u0432\u0430\u043B\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u044F");
    label_kvalification.setBounds(10, 190, 147, 14);
    contentPane.add(label_kvalification);

    textField_phone = new JTextField();
    textField_phone.setBounds(167, 134, 186, 20);
    contentPane.add(textField_phone);
    textField_phone.setColumns(10);

    textField_date.setBounds(167, 109, 186, 20);
    contentPane.add(textField_date);

    label_id_hidden.setFont(new Font("Tahoma", Font.BOLD, 12));
    label_id_hidden.setBounds(143, 11, 122, 14);
    contentPane.add(label_id_hidden);

    button_insert.setBounds(83, 230, 160, 23);
    contentPane.add(button_insert);

    button_cancel.setBounds(264, 230, 104, 23);
    contentPane.add(button_cancel);

    button_update.setBounds(83, 230, 160, 23);
    contentPane.add(button_update);

    JButton button_plus_doljnost = new JButton("+");
    button_plus_doljnost.addActionListener(
        new ActionListener() {
          @SuppressWarnings("deprecation")
          public void actionPerformed(ActionEvent arg0) {
            DoljnostDialog d = new DoljnostDialog();
            d.setTitle("Добавление должности");
            d.show();
          }
        });
    button_plus_doljnost.setBounds(359, 159, 41, 23);
    contentPane.add(button_plus_doljnost);

    JButton button_plus_kvalification = new JButton("+");
    button_plus_kvalification.addActionListener(
        new ActionListener() {
          @SuppressWarnings("deprecation")
          public void actionPerformed(ActionEvent arg0) {
            KvalificationDialog d = new KvalificationDialog();
            d.setTitle("Добавление квалификации");
            d.show();
          }
        });
    button_plus_kvalification.setBounds(359, 184, 41, 23);
    contentPane.add(button_plus_kvalification);

    JLabel label =
        new JLabel(
            "\u041F\u043E\u043B\u044F, \u043E\u0442\u043C\u0435\u0447\u0435\u043D\u043D\u044B\u0435 ");
    label.setBounds(60, 264, 122, 14);
    contentPane.add(label);

    JLabel label_3 = new JLabel("*");
    label_3.setForeground(Color.RED);
    label_3.setFont(new Font("Tahoma", Font.BOLD, 11));
    label_3.setBounds(186, 264, 12, 14);
    contentPane.add(label_3);

    JLabel label_4 =
        new JLabel(
            "\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B  \u0434\u043B\u044F \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F!");
    label_4.setBounds(197, 264, 203, 14);
    contentPane.add(label_4);

    JLabel label_5 = new JLabel("*");
    label_5.setForeground(Color.RED);
    label_5.setFont(new Font("Tahoma", Font.BOLD, 11));
    label_5.setBounds(356, 37, 12, 14);
    contentPane.add(label_5);

    JLabel label_1 = new JLabel("*");
    label_1.setForeground(Color.RED);
    label_1.setFont(new Font("Tahoma", Font.BOLD, 11));
    label_1.setBounds(356, 62, 12, 14);
    contentPane.add(label_1);

    comboBox_doljnost.setBounds(167, 159, 186, 20);
    contentPane.add(comboBox_doljnost);

    comboBox_kvalification.setBounds(167, 187, 186, 20);
    contentPane.add(comboBox_kvalification);

    // Actions for button "Добавить"
    button_insert.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (!textField_familiya.getText().equals("") && !textField_imya.getText().equals("")) {
              try {
                Sotrudnik s = new Sotrudnik();
                s.setFamiliya(textField_familiya.getText());
                s.setImya(textField_imya.getText());
                s.setOtchestvo(textField_otchestvo.getText());
                s.setData_priema(Date.valueOf(textField_date.getText()));
                s.setPhone(textField_phone.getText());
                Doljnost d = (Doljnost) comboBox_doljnost.getSelectedItem();
                s.setId_doljnosti(d.getId_doljnosti());
                Kvalification k = (Kvalification) comboBox_kvalification.getSelectedItem();
                s.setId_kvalification(k.getId_kvalification());

                DBClass db = new DBClass();
                db.sotrudnikUpsert(s, "INSERT");
                MyFrame.updateList();
                ZakazDialog.updateSotrudnik();
              } catch (SQLException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(panelException, e.getMessage());
              } catch (ClassNotFoundException ee) {
                ee.printStackTrace();
                JOptionPane.showMessageDialog(panelException, ee.getMessage());
              } finally {
                dispose();
              }
            } else JOptionPane.showMessageDialog(null, "Введите обязательные параметры!");
          }
        });

    // Actions for button "Отмена"
    button_cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            dispose();
          }
        });

    // Actions for button "Сохранить изменения"
    button_update.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (!textField_familiya.getText().equals("")
                && !textField_imya.getText().equals("")
                && !textField_date.getText().equals("")) {
              if (textField_date.getText().length() == 10) {
                try {
                  Integer.parseInt((textField_date.getText().substring(0, 3)));
                  Integer.parseInt((textField_date.getText().substring(5, 6)));
                  Integer.parseInt((textField_date.getText().substring(8, 9)));

                  Sotrudnik s = new Sotrudnik();
                  s.setId_sotrudnika(Integer.parseInt(label_id_hidden.getText()));
                  s.setFamiliya(textField_familiya.getText());
                  s.setImya(textField_imya.getText());
                  s.setOtchestvo(textField_otchestvo.getText());
                  s.setPhone(textField_phone.getText());

                  Doljnost d = (Doljnost) comboBox_doljnost.getSelectedItem();
                  s.setId_doljnosti(d.getId_doljnosti());

                  Kvalification k = (Kvalification) comboBox_kvalification.getSelectedItem();
                  s.setId_kvalification(k.getId_kvalification());

                  DBClass db = new DBClass();
                  db.sotrudnikUpsert(s, "UPDATE");
                  MyFrame.updateList();
                  dispose();
                } catch (NumberFormatException e) {
                  JOptionPane.showMessageDialog(panelException, e.getMessage());
                } catch (SQLException e) {
                  // e.printStackTrace();
                  JOptionPane.showMessageDialog(panelException, e.getMessage());
                } catch (ClassNotFoundException ee) {
                  // ee.printStackTrace();
                  JOptionPane.showMessageDialog(panelException, ee.getMessage());
                }
              } else JOptionPane.showMessageDialog(null, "Введите дату в правильном формате!");
            } else JOptionPane.showMessageDialog(null, "Введите обязательные параметры!");
          }
        });
  }
コード例 #8
0
  public vehicle() {
    message = new JLabel("VEHICLE  DETAILS");
    mname = new JLabel("Model Name");
    cap = new JLabel("Capacity");
    cc = new JLabel("CC");
    eng = new JLabel("Engine");
    stroke = new JLabel("Stroke");
    bhp = new JLabel("BHP");
    volt = new JLabel("Volts");
    rpm = new JLabel("RPM");
    weight = new JLabel("Weight");
    kg = new JLabel("Kg");
    gear = new JLabel("Gears");
    color = new JLabel("Color");

    jcmname = new JComboBox();

    tfcap = new JTextField(30);
    tfeng = new JTextField(20);
    tfbhp = new JTextField(10);
    tfvolt = new JTextField(20);
    tfrpm = new JTextField(20);
    tfweight = new JTextField(20);
    tfgear = new JTextField(30);

    jccolor = new JComboBox();

    ok = new JButton("OK");
    can = new JButton("CANCEL");

    can.addActionListener(this);
    can.setActionCommand("can");
    ok.addActionListener(this);
    ok.setActionCommand("Ok");

    Container c = getContentPane();

    setSize(800, 600);
    setTitle("Vehicle Details");
    c.setLayout(null);
    setVisible(true);

    c.add(message);
    c.add(mname);
    c.add(cap);
    c.add(cc);
    c.add(eng);
    c.add(stroke);
    c.add(bhp);
    c.add(volt);
    c.add(rpm);
    c.add(weight);
    c.add(kg);
    c.add(gear);
    c.add(color);

    c.add(jcmname);

    c.add(tfcap);
    c.add(tfeng);
    c.add(tfbhp);
    c.add(tfvolt);
    c.add(tfrpm);
    c.add(tfweight);
    c.add(tfgear);

    c.add(jccolor);

    c.add(ok);
    c.add(can);
    c.setBackground(Color.pink);

    message.setBounds(300, 40, 200, 50);
    mname.setBounds(50, 100, 100, 30);
    cap.setBounds(50, 150, 100, 30);
    cc.setBounds(275, 150, 50, 30);
    eng.setBounds(50, 200, 50, 30);
    stroke.setBounds(275, 200, 100, 30);
    bhp.setBounds(50, 250, 100, 30);
    volt.setBounds(50, 300, 100, 30);
    rpm.setBounds(50, 350, 100, 30);
    weight.setBounds(50, 400, 50, 30);
    kg.setBounds(275, 400, 100, 30);
    gear.setBounds(450, 150, 150, 30);
    color.setBounds(450, 200, 100, 30);

    jcmname.setBounds(200, 100, 100, 30);
    jcmname.addItem(" -- Select --");
    jcmname.addItem("Pulsar");
    jcmname.addItem("CT 100");
    jcmname.addItem("Discover DTS-i");
    jcmname.addItem("Wave DTS-i");

    tfcap.setBounds(200, 150, 70, 30);
    tfeng.setBounds(200, 200, 70, 30);
    tfbhp.setBounds(200, 250, 70, 30);
    tfvolt.setBounds(200, 300, 70, 30);
    tfrpm.setBounds(200, 350, 70, 30);
    tfweight.setBounds(200, 400, 70, 30);
    tfgear.setBounds(500, 150, 70, 30);

    jccolor.setBounds(500, 200, 100, 30);
    jccolor.addItem("Black");
    jccolor.addItem("Blue");
    jccolor.addItem("Red");
    jccolor.addItem("Grey");

    ok.setBounds(270, 480, 85, 30);
    can.setBounds(370, 480, 85, 30);
  }
  public Design() throws Exception {
    super.setBackground(Color.BLACK);
    this.setTitle("");
    con = getContentPane();
    con.setLayout(null);
    dim = tk.getDefaultToolkit().getScreenSize();
    this.setTitle("Customer Peer Login");

    l1 = new JLabel(new ImageIcon("plain.jpg"));
    l1.setBounds(0, 0, 400, 400);
    con.add(l1);
    l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black));

    title = new JLabel("CUSTOMER PEER LOGIN ");
    title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20));
    title.setForeground(Color.red);
    title.setBounds(80, 30, 300, 30);
    l1.add(title);

    l4 = new JLabel("CMACHINE NAME");
    l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l4.setForeground(Color.BLUE);
    l4.setBounds(70, 100, 160, 20);
    //	l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green));

    l1.add(l4);
    jtf2 = new JTextField();
    jtf2.setBounds(250, 100, 100, 20);
    jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jtf2);

    l2 = new JLabel("CUSER LOGIN");
    l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l2.setForeground(Color.blue);
    l2.setBounds(70, 150, 120, 20);
    l1.add(l2);

    jtf1 = new JTextField();
    jtf1.setBounds(250, 150, 100, 20);
    jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jtf1);

    l3 = new JLabel("CPASSWORD");
    l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l3.setForeground(Color.blue);
    l3.setBounds(70, 200, 120, 20);
    l1.add(l3);

    jptf1 = new JPasswordField();
    jptf1.setBounds(250, 200, 100, 20);
    jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jptf1);

    JLabel l4 = new JLabel("DAgent");
    l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l4.setForeground(Color.blue);
    l4.setBounds(70, 250, 120, 20);
    l1.add(l4);

    box = new JComboBox();
    box.setBounds(250, 250, 100, 20);
    box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));
    l1.add(box);

    b2 = new JButton("Register");
    b2.setBounds(50, 300, 100, 20);
    l1.add(b2);
    b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));

    b3 = new JButton("Login");
    b3.setBounds(150, 300, 100, 20);
    b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));
    l1.add(b3);

    b1 = new JButton("Cancel");
    b1.setBounds(250, 300, 100, 20);
    b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));

    l1.add(b1);

    b1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            dispose();
          }
        });

    try {

      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      conn = DriverManager.getConnection("jdbc:odbc:agent");

    } catch (Exception exp) {

    }

    try {
      Statement satem = conn.createStatement();
      ResultSet rsatem = satem.executeQuery("select * from Dagent");
      while (rsatem.next()) {
        String namem = rsatem.getString("uname");
        box.addItem(namem);
      }

    } catch (Exception expo1) {

    }

    b2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            String username = jtf1.getText().trim();
            String password = jptf1.getText().trim();
            String mechine = jtf2.getText().trim();
            String dname = box.getSelectedItem().toString();
            int porte = 0;

            try {
              Statement sate = conn.createStatement();
              ResultSet rsate =
                  sate.executeQuery("select * from Dagent where uname='" + dname + "'");
              if (rsate.next()) {
                servermachine = rsate.getString("umechine");
                porte = rsate.getInt("ulistport");
                System.out.println(servermachine);
              }
              System.out.println(servermachine);

            } catch (Exception exp) {
              exp.printStackTrace();
            }

            try {
              packet p = new packet();
              p.setaction("Creg");
              p.setCuser(username);
              p.setCpass(password);
              p.setCmname(mechine);
              p.setCDpeer(dname);
              Socket soc = new Socket(servermachine, porte);
              ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream());
              out.writeObject(p);
              ObjectInputStream in = new ObjectInputStream(soc.getInputStream());
              packet rpac = (packet) in.readObject();
              if (rpac.getaction().equals("ok")) {

                JOptionPane.showMessageDialog(null, "Sucessfully Registered");

                jtf2.setText("");
                jtf1.setText("");
                jptf1.setText("");

              } else {

                JOptionPane.showMessageDialog(null, "Already Registered");
                jtf2.setText("");
                jtf1.setText("");
                jptf1.setText("");
              }

            } catch (Exception exp) {
            }
          }
        });

    b3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            String username = jtf1.getText().trim();
            String password = jptf1.getText().trim();
            String mechine = jtf2.getText().trim();
            String Dname = box.getSelectedItem().toString();

            int porte = 0;

            try {
              Statement sate = conn.createStatement();
              ResultSet rsate =
                  sate.executeQuery("select * from Dagent where uname='" + Dname + "'");
              if (rsate.next()) {
                servermachine = rsate.getString("umechine");
                porte = rsate.getInt("ulistport");
                System.out.println(servermachine);
              }
              System.out.println(servermachine);

            } catch (Exception exp) {

            }

            try {

              packet p1 = new packet();
              p1.setaction("clogin");
              p1.setCuser(username);
              p1.setCpass(password);
              p1.setCmname(mechine);
              p1.setCDpeer(Dname);
              Socket soc1 = new Socket(servermachine, porte);
              ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream());
              out1.writeObject(p1);
              ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream());
              packet rpac1 = (packet) in1.readObject();
              if (rpac1.getaction().equals("ok")) {
                int port1 = 0;
                try {

                  int portm = rpac1.getCport();
                  System.out.println("XXXXXXX" + portm);
                  //	JOptionPane.showMessageDialog(null,"Sucessfully Started");

                  new Listen(portm);
                  new process(username, portm);
                  dispose();
                } catch (Exception exp) {
                }
              } else {
                JOptionPane.showMessageDialog(
                    null, "Enter valid username and password", "Server reply", 2);
                jtf1.setText("");
                jtf2.setText("");
                jptf1.setText("");
              }

            } catch (Exception exp) {
            }
          }
        });

    setSize(400, 400);
    show();
    setLocation(150, 100);
    setResizable(false);
  }