예제 #1
0
  public PasswordField(String label) {
    setLayout(new BorderLayout());
    m_label = new JLabel(label);

    if (label.length() > 0) {
      m_label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    }
    add(m_label, BorderLayout.WEST);

    m_password = new JPasswordField();
    m_password.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            m_support.firePropertyChange("", null, null);
          }
        });
    m_password.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            super.focusLost(e);
            m_support.firePropertyChange("", null, null);
          }
        });

    add(m_password, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  }
  /**
   * This method initializes passwordField
   *
   * @return javax.swing.JPasswordField
   */
  private JPasswordField getPasswordField() {
    if (passwordField == null) {
      passwordField = new JPasswordField();
      passwordField.addKeyListener(this);
      passwordField.setBounds(new java.awt.Rectangle(155, 222, 166, 21));
    }

    return passwordField;
  }
예제 #3
0
  public FormLogin() {

    setResizable(false);
    setTitle("User Login");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(0, 0, 270, 219);
    setLocationRelativeTo(null);

    getContentPane().setLayout(null);

    JButton btnLogin = new JButton("Login");
    btnLogin.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            login();
          }
        });
    btnLogin.setBounds(32, 133, 196, 28);
    getContentPane().add(btnLogin);

    JLabel lblUsername = new JLabel("Username");
    lblUsername.setBounds(32, 38, 83, 14);
    getContentPane().add(lblUsername);

    txtUsername = new JTextField();
    txtUsername.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              login();
            }
          }
        });
    txtUsername.setBounds(32, 56, 196, 20);
    getContentPane().add(txtUsername);
    txtUsername.setColumns(10);

    JLabel lblPassword = new JLabel("Password");
    lblPassword.setBounds(32, 84, 83, 14);
    getContentPane().add(lblPassword);

    txtPassword = new JPasswordField();
    txtPassword.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              login();
            }
          }
        });
    txtPassword.setBounds(32, 102, 197, 20);
    getContentPane().add(txtPassword);
  }
예제 #4
0
  private void initComponents() {

    btLogin.setFocusable(false); // Fókusz letiltása
    btSettings.setFocusable(false); // Fókusz letiltása

    btLogin.setBackground(Color.lightGray); // A "bejelentkezés" gomb háttérszínének beállítása
    btSettings.setBackground(
        pnLogin.getBackground()); // A "Beállítások" gomb háttérszínének beállítása

    tfUsername.setPreferredSize(new Dimension(120, 25)); // Szövegmező átméretezése
    pfPassword.setPreferredSize(new Dimension(120, 25)); // Jelszómező átméretezése

    tfUsername.addKeyListener(btEnabler); // A figyelő hozzáadása a felhasználónév mezőhőz
    pfPassword.addKeyListener(btEnabler); // A figyelő hozzáadása a jelszó mezőhőz
  }
예제 #5
0
  public RegistrationForm() {
    super("Registration Form");
    setLayout(new GridLayout(10, 2));
    add(new JLabel("Name:"));
    add(txtName);
    add(new JLabel("Password:"******"Verify Password:"******"Gender:"));
    add(pnlGender);
    pnlGender.add(rbMale);
    pnlGender.add(rbFemale);
    add(new JLabel("Phone"));
    add(pnlPhone);
    pnlPhone.add(txtPhone);
    pnlPhone.add(cmbPhoneType);
    add(new JLabel("Email:"));
    add(txtEmail);
    add(new JLabel("Preferred Contact:"));
    add(pnlContact);
    pnlContact.add(cbEmail);
    pnlContact.add(cbPhone);
    add(new JLabel());
    add(new JLabel());
    add(lblMouse);
    add(new JLabel());
    add(lblMessage);
    add(btnSubmit);

    grpGender.add(rbMale);
    grpGender.add(rbFemale);

    mouseHandler h = new mouseHandler();
    this.addMouseListener(h);
    this.addMouseMotionListener(h);

    txtVerify.addKeyListener(new keyHandler());
    txtName.addFocusListener(new focusHandler());
    txtPhone.addFocusListener(new focusHandler());
    txtEmail.addFocusListener(new focusHandler());
    btnSubmit.addActionListener(new butonHandler());
  }
예제 #6
0
 /**
  * This method initializes jPasswordField
  *
  * @return javax.swing.JPasswordField
  */
 private JPasswordField getPasswordField() {
   if (passwordField == null) {
     passwordField = new JPasswordField();
     passwordField.setPreferredSize(new java.awt.Dimension(150, 20));
     passwordField.setLocation(92, 38);
     passwordField.setSize(150, 20);
     passwordField.setText(password);
     // passwordField.setFocusable(true);
     passwordField.addKeyListener(
         new java.awt.event.KeyAdapter() {
           public void keyPressed(java.awt.event.KeyEvent e) {
             // NeptusLog.pub().info("<###>keyPressed()");
             if (e.getKeyCode() == KeyEvent.VK_ENTER) okAction();
           }
         });
     passwordField.setSelectionStart(0);
     passwordField.setSelectionEnd(passwordField.getPassword().length);
   }
   return passwordField;
 }
예제 #7
0
  public CatPassword() {
    this.setIconImage(Toolkit.getDefaultToolkit().getImage("imagen/Key.png"));

    this.setTitle("Password Empleado");

    int x = 40, y = 30, ancho = 140;
    campos.setBorder(BorderFactory.createTitledBorder("Entra al Sistema"));

    campos.add(new JLabel("Usuario Id:")).setBounds(x, y, ancho, 20);
    campos.add(txtFolio).setBounds(x + ancho - 60, y, ancho, 20);
    campos.add(btnBuscar).setBounds(x + ancho + ancho, y, 40, 20);

    campos.add(new JLabel("Nombre:")).setBounds(x, y += 25, ancho, 20);
    campos.add(txtNombre).setBounds(x + ancho - 60, y, ancho * 2, 20);

    campos.add(new JLabel("Contraseña:")).setBounds(x, y += 25, ancho, 20);
    campos.add(pxpClave).setBounds(x + ancho - 60, y, ancho * 2, 20);

    campos.add(btnDeshacer).setBounds(x + ancho - 60, y += 25, 90, 20);
    campos.add(btnSalir).setBounds(x + ancho + 40, y, 85, 20);
    campos.add(btnAceptar).setBounds(x + ancho + 135, y, 85, 20);

    txtFolio.addKeyListener(validaNumerico);
    txtFolio.addKeyListener(validaBuscar);
    btnBuscar.addActionListener(buscar);
    btnAceptar.addActionListener(aceptarAction);
    btnSalir.addActionListener(salir);
    btnDeshacer.addActionListener(deshacer);

    pxpClave.addKeyListener(validaGuardar);

    cont.add(campos);

    this.setModal(true);
    this.setSize(450, 180);
    this.setResizable(false);
    this.setLocationRelativeTo(null);
  }
예제 #8
0
  protected void dolayout(String strDir, String strFreq, String strTraynum) {
    // TopBar
    String strTitle = gettitle(strFreq);
    Color color = DisplayOptions.getColor("Heading3");

    // Center Panel
    JPanel panelCenter = new JPanel(new GridBagLayout());
    GridBagConstraints gbc =
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.2,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0);
    ImageIcon icon = getImageIcon();
    // panelCenter.add(new JLabel(icon));
    addComp(panelCenter, new JLabel(icon), gbc, 0, 0);
    strTitle = getSampleName(strDir, strTraynum);
    m_lblSampleName = new JLabel(strTitle);
    if (strTitle == null || !strTitle.trim().equals("")) strTitle = "3";
    Font font = m_lblSampleName.getFont();
    font = DisplayOptions.getFont(font.getName(), Font.BOLD, 300);
    m_lblSampleName.setFont(font);
    m_lblSampleName.setForeground(color);
    // panelCenter.add(m_lblSampleName);
    m_pnlSampleName = new JPanel(new CardLayout());
    m_pnlSampleName.add(m_lblSampleName, OTHER);
    addComp(panelCenter, m_pnlSampleName, gbc, 1, 0);
    m_pnlSampleName.setVisible(false);
    m_pnlTrays = new JPanel(new GridLayout(1, 0));
    // Vast panels
    VBox pnlVast1 = new VBox(m_pnlTrays, "1");
    m_pnlTrays.add(pnlVast1);
    m_pnlVast[0] = pnlVast1;
    VBox pnlVast2 = new VBox(m_pnlTrays, "2");
    m_pnlTrays.add(pnlVast2);
    m_pnlVast[1] = pnlVast2;
    VBox pnlVast3 = new VBox(m_pnlTrays, "3");
    m_pnlTrays.add(pnlVast3);
    m_pnlVast[2] = pnlVast3;
    VBox pnlVast4 = new VBox(m_pnlTrays, "4");
    m_pnlTrays.add(pnlVast4);
    m_pnlVast[3] = pnlVast4;
    VBox pnlVast5 = new VBox(m_pnlTrays, "5");
    m_pnlTrays.add(pnlVast5);
    m_pnlVast[4] = pnlVast5;
    m_pnlSampleName.add(m_pnlTrays, VAST);

    // Login Panel
    JPanel panelThird = new JPanel(new BorderLayout());
    JPanel panelLogin = new JPanel(new GridBagLayout());
    gbc = new GridBagConstraints();
    panelThird.add(panelLogin);
    Object[] aStrUser = getOperators();
    m_cmbUser = new JComboBox(aStrUser);
    BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();
    m_cmbUser.setRenderer(renderer);
    m_cmbUser.setEditable(true);
    m_passwordField = new JPasswordField();
    // *Warning, working around a Java problem*
    // When we went to the T3500 running Redhat 5.3, the JPasswordField
    // fields sometimes does not allow ANY entry of characters.  Setting
    // the enableInputMethods() to true fixed this problem.  There are
    // comments that indicate that this could cause the typed characters
    // to be visible.  I have not found that to be a problem.
    // This may not be required in the future, or could cause characters
    // to become visible in the future if Java changes it's code.
    // GRS  8/20/09
    m_passwordField.enableInputMethods(true);

    m_lblLogin = new VLoginLabel(null, "Incorrect username/password \n Please try again ", 0, 0);
    m_lblLogin.setVisible(false);
    okButton.setActionCommand("enter");
    okButton.addActionListener(this);
    cancelButton.setActionCommand("cancel");
    cancelButton.addActionListener(this);
    helpButton.setActionCommand("help");
    helpButton.addActionListener(this);
    m_passwordField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) enterLogin();
          }
        });

    // These is some wierd problem such that sometimes, the vnmrj command
    // area gets the focus and these items in the login box do not get
    // the focus.  Even clicking in these items does not bring focus to
    // them.  Issuing requestFocus() does not bring focus to them.
    // I can however, determing if either the operator entry box or
    // the password box has focus and if neither does, I can unshow and
    // reshow the panel and that fixes the focus.  So, I have added this
    // to the mouseClicked action.  If neither has focus, it will
    // take focus with setVisible false then true.
    comboTextField = m_cmbUser.getEditor().getEditorComponent();
    m_passwordField.addMouseListener(this);
    comboTextField.addMouseListener(this);

    m_lblUsername = new JLabel(Util.getLabel("_Operator"));
    addComp(panelLogin, m_lblUsername, gbc, 0, 0);
    addComp(panelLogin, m_cmbUser, gbc, 1, 0);
    m_lblPassword = new JLabel(Util.getLabel("_Password"));
    addComp(panelLogin, m_lblPassword, gbc, 0, 1);
    addComp(panelLogin, m_passwordField, gbc, 1, 1);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    addComp(panelLogin, m_lblLogin, gbc, 2, 0);
    setPref();

    Container container = getContentPane();
    JPanel panelLoginBox = new JPanel(new BorderLayout());
    panelLoginBox.add(panelCenter, BorderLayout.CENTER);
    panelLoginBox.add(panelThird, BorderLayout.SOUTH);
    container.add(panelLoginBox, BorderLayout.CENTER);
  }
  /**
   * Called by constructors to initialize the dialog.
   *
   * @since ostermillerutils 1.00.00
   */
  @Override
  protected void dialogInit() {

    if (labels == null) {
      setLocale(Locale.getDefault());
    }

    name = new JTextField("", 20);
    pass = new JPasswordField("", 20);
    okButton = new JButton(labels.getString("dialog.ok"));
    cancelButton = new JButton(labels.getString("dialog.cancel"));
    nameLabel = new JLabel(labels.getString("dialog.name") + " ");
    passLabel = new JLabel(labels.getString("dialog.pass") + " ");

    super.dialogInit();

    KeyListener keyListener =
        (new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE
                || (e.getSource() == cancelButton && e.getKeyCode() == KeyEvent.VK_ENTER)) {
              pressed_OK = false;
              PasswordDialog.this.setVisible(false);
            }
            if (e.getSource() == okButton && e.getKeyCode() == KeyEvent.VK_ENTER) {
              pressed_OK = true;
              PasswordDialog.this.setVisible(false);
            }
          }
        });
    addKeyListener(keyListener);

    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            if (source == name) {
              // the user pressed enter in the name field.
              name.transferFocus();
            } else {
              // other actions close the dialog.
              pressed_OK = (source == pass || source == okButton);
              PasswordDialog.this.setVisible(false);
            }
          }
        };

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.insets.top = 5;
    c.insets.bottom = 5;
    JPanel pane = new JPanel(gridbag);
    pane.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));
    c.anchor = GridBagConstraints.EAST;
    gridbag.setConstraints(nameLabel, c);
    pane.add(nameLabel);

    gridbag.setConstraints(name, c);
    name.addActionListener(actionListener);
    name.addKeyListener(keyListener);
    pane.add(name);

    c.gridy = 1;
    gridbag.setConstraints(passLabel, c);
    pane.add(passLabel);

    gridbag.setConstraints(pass, c);
    pass.addActionListener(actionListener);
    pass.addKeyListener(keyListener);
    pane.add(pass);

    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.CENTER;
    JPanel panel = new JPanel();
    okButton.addActionListener(actionListener);
    okButton.addKeyListener(keyListener);
    panel.add(okButton);
    cancelButton.addActionListener(actionListener);
    cancelButton.addKeyListener(keyListener);
    panel.add(cancelButton);
    gridbag.setConstraints(panel, c);
    pane.add(panel);

    getContentPane().add(pane);

    pack();
  }
  /** Create the panel. */
  public TorrentClientSectionConfig(ConfigView parentView, Manager manager) {
    super(parentView);
    setManager(manager);
    setInitialVariables();

    setBackground(PanelProperties.BACKGROUND);
    JLabel lblNewLabel = new JLabel("RPC Server");
    lblNewLabel.setFont(new Font("Calibri", Font.PLAIN, 15));

    userLabel = new JLabel("Usuario");
    userLabel.setFont(new Font("Calibri", Font.PLAIN, 15));
    userLabel.setBackground(PanelProperties.TRANSPARENT_BACKGROUND);

    passwordLabel = new JLabel("Password");
    passwordLabel.setFont(new Font("Calibri", Font.PLAIN, 15));
    passwordLabel.setBackground(PanelProperties.TRANSPARENT_BACKGROUND);

    userField = new JTextField();
    userField.setFont(new Font("Calibri", Font.PLAIN, 15));
    userField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            userField.selectAll();
          }
        });
    userField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            TorrentClientSectionConfig.this.parentView.keyReleased(e);
          }
        });
    userField.setColumns(10);

    passwordField = new JPasswordField();
    passwordField.setFont(new Font("Calibri", Font.PLAIN, 15));
    passwordField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            passwordField.selectAll();
          }
        });
    passwordField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            TorrentClientSectionConfig.this.parentView.keyReleased(e);
          }
        });

    needsAuthCheckBox = new JCheckBox("Necesita autenticaci\u00F3n");
    needsAuthCheckBox.setFont(new Font("Calibri", Font.PLAIN, 15));
    needsAuthCheckBox.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_SPACE) {
              needsAuthCheckBox.doClick();
            } else {
              TorrentClientSectionConfig.this.parentView.keyReleased(e);
            }
          }
        });
    needsAuthCheckBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            JCheckBox checkBox = (JCheckBox) arg0.getSource();
            if (!checkBox.isSelected()) {
              userField.setText("");
              passwordField.setText("");
            }
            enableAuthFields(checkBox.isSelected());
          }
        });

    needsAuthCheckBox.setSelected(initialNeedsAuth);
    enableAuthFields(initialNeedsAuth);
    userField.setText(initialUser);
    passwordField.setText(initialPassword);

    rpcServerField = new JTextField();
    rpcServerField.setFont(new Font("Calibri", Font.PLAIN, 15));
    rpcServerField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            rpcServerField.selectAll();
          }
        });
    rpcServerField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            TorrentClientSectionConfig.this.parentView.keyReleased(e);
          }
        });
    rpcServerField.setColumns(10);
    setRPCFieldText(initialRpcServer);

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.TRAILING)
            .addGroup(
                Alignment.LEADING,
                groupLayout
                    .createSequentialGroup()
                    .addGap(48)
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.LEADING, false)
                            .addComponent(needsAuthCheckBox)
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addComponent(lblNewLabel)
                                    .addPreferredGap(
                                        ComponentPlacement.RELATED,
                                        GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                    .addComponent(
                                        rpcServerField,
                                        GroupLayout.PREFERRED_SIZE,
                                        224,
                                        GroupLayout.PREFERRED_SIZE))
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addGroup(
                                        groupLayout
                                            .createParallelGroup(Alignment.LEADING)
                                            .addComponent(userLabel)
                                            .addComponent(passwordLabel))
                                    .addGap(38)
                                    .addGroup(
                                        groupLayout
                                            .createParallelGroup(Alignment.LEADING, false)
                                            .addComponent(passwordField)
                                            .addComponent(
                                                userField,
                                                GroupLayout.PREFERRED_SIZE,
                                                225,
                                                GroupLayout.PREFERRED_SIZE))))
                    .addContainerGap(97, Short.MAX_VALUE)));
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addGap(36)
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(lblNewLabel)
                            .addComponent(
                                rpcServerField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addGap(19)
                    .addComponent(needsAuthCheckBox)
                    .addGap(18)
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(userLabel)
                            .addComponent(
                                userField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addGap(28)
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(passwordLabel)
                            .addComponent(
                                passwordField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(36, Short.MAX_VALUE)));
    setLayout(groupLayout);
  }
예제 #11
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);
            }
          }
        });
  }
  public GUILogin(ResourceBundle bn) {

    this.bn = bn;

    Container c = getContentPane();
    c.setLayout(null);

    image = new ImageIcon(getClass().getResource("/telas/iconlogin.png"));
    limage = new JLabel(image);

    logo = new ImageIcon(getClass().getResource("/telas/bsr.png"));
    llogo = new JLabel(logo);

    bok = new JButton(bn.getString("guilogin.ok"));
    bsair = new JButton(bn.getString("guilogin.sair"));

    llogin = new JLabel(bn.getString("guilogin.login"));
    lsenha = new JLabel(bn.getString("guilogin.senha"));

    tlogin = new JTextField(15);
    tsenha = new JPasswordField(15);

    // Setbounds... localização dos textfields, botoes e labels  na tela

    limage.setBounds(-60, -35, 250, 310);
    llogo.setBounds(200, -120, 250, 310);
    llogin.setBounds(180, 105, 70, 30);
    tlogin.setBounds(250, 110, 120, 20);
    lsenha.setBounds(180, 140, 70, 20);
    tsenha.setBounds(250, 140, 120, 20);
    bok.setBounds(240, 200, 60, 20);
    bsair.setBounds(310, 200, 60, 20);

    c.add(llogin);
    c.add(tlogin);
    c.add(lsenha);
    c.add(tsenha);
    c.add(bok);
    c.add(bsair);
    c.add(limage);
    // c.add(llogo);

    bok.addActionListener(this);
    bsair.addActionListener(this);
    tsenha.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == 10) {
              logar();
            }
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void keyTyped(KeyEvent e) {
            // TODO Auto-generated method stub

          }
        });

    setTitle(bn.getString("guilogin.titulo"));
    setVisible(true);
    setSize(500, 285);
    setResizable(false);
    this.setLocationRelativeTo(null);
  }
예제 #13
0
  public void logButtonFunctions() {

    loginButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            String email = emailF.getText();

            char[] input = passF.getPassword();
            String password = "";
            for (int i = 0; i < input.length; i++) {
              password += input[i];
            }
            try {
              if (func.checkEmailAndPassword(email, password) == true) { // if
                // email
                // and
                // password
                func.login(email, password);

                if (func.checkActivation(email) == true) { // if account
                  // not
                  // activated
                  // and
                  // password
                  // and email
                  // are true
                  // the
                  // student
                  // is
                  // directed
                  // to main
                  // page
                  window.dispose();
                  SendMsg.notifyUser();
                  // *** here instead of Search Frame I introduce another Frame
                  // *** "HomePage", 'Search' is just one of panel in this new JFrame
                  //							Search GUI = new Search();
                  //							GUI.run();

                } else {
                  JOptionPane.showMessageDialog(null, "Wrong Code Entered ");
                }
              } else {
                JOptionPane.showMessageDialog(null, "Please Check your Email or Password");
                return;
              }

            } catch (Exception e1) {

              e1.printStackTrace();
            }
          }
        });
    passF.addKeyListener(
        new KeyListener() {

          @Override
          public void keyTyped(KeyEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              //					System.out.println("hi");
              //				}
              //
              //	if(fName.getText().isEmpty()&&lName.getText().isEmpty()&&passF.getText().isEmpty()&&emailF.getText().isEmpty()&&!female.isSelected()&&!male.isSelected()&&!emailSign.getText().isEmpty()&&){
              String email = emailF.getText();

              char[] input = passF.getPassword();
              String password = "";
              for (int i = 0; i < input.length; i++) {
                password += input[i];
              }
              try {
                if (func.checkEmailAndPassword(email, password) == true) { // if
                  // email
                  // and
                  // password
                  func.login(email, password);

                  if (func.checkActivation(email) == true) { // if account
                    // not
                    // activated
                    // and
                    // password
                    // and email
                    // are true
                    // the
                    // student
                    // is
                    // directed
                    // to main
                    // page
                    window.dispose();
                    SendMsg.notifyUser();
                    // *** here instead of Search Frame I introduce another Frame
                    // *** "HomePage", 'Search' is just one of panel in this new JFrame
                    //									Search GUI = new Search();
                    //									GUI.run();

                  } else {
                    JOptionPane.showMessageDialog(null, "Wrong Code Entered ");
                  }
                } else {
                  JOptionPane.showMessageDialog(null, "Please Check your Email or Password");
                  return;
                }

              } catch (Exception e1) {

                e1.printStackTrace();
              }
            }
            //				}
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // TODO Auto-generated method stub

          }
        });

    cantAccess.addActionListener(
        new ActionListener() { // if can't access
          // account

          @Override
          public void actionPerformed(ActionEvent e) {
            String email = JOptionPane.showInputDialog("Please enter your email");
            if (email == null) return;
            try {
              func.generateNewPassword(email);
            } catch (Exception e1) {
              JOptionPane.showMessageDialog(null, "Email doesn't Exist ! ");
              e1.printStackTrace();
            }
          }
        });
  }
예제 #14
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">
  private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    lableWelcome = new javax.swing.JLabel();
    lableUser = new javax.swing.JLabel();
    labelPassword = new javax.swing.JLabel();
    btnLogIn = new javax.swing.JButton();
    txtfldPassword = new javax.swing.JPasswordField("Password", 8);
    txtfldUserName = new javax.swing.JTextField();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jPanel1.setBackground(new java.awt.Color(0, 51, 255));
    jPanel1.setBorder(
        javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 102)));

    lableWelcome.setFont(new java.awt.Font("Times New Roman", 1, 18));
    lableWelcome.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lableWelcome.setText("Please Log In To Proceed");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                lableWelcome,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(lableWelcome)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    lableUser.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
    lableUser.setText("User Name:");

    labelPassword.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
    labelPassword.setText("Password   :"******"Times New Roman", 1, 14)); // NOI18N
    btnLogIn.setText("Log In");
    btnLogIn.addActionListener(
        new java.awt.event.ActionListener() {
          @Override
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            try {
              try {
                logIn(evt);
              } catch (SQLException ex) {
                Logger.getLogger(LogIn.class.getName()).log(Level.SEVERE, null, ex);
              }
            } catch (ClassNotFoundException ex) {
              Logger.getLogger(LogIn.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });

    // Create key listener that will listen when someone press Backspace key
    KeyListener kl =
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
              txtfldPassword.setEditable(true);
            }
          }
        };

    CaretListener caretListener =
        new CaretListener() {
          @Override
          public void caretUpdate(CaretEvent event) {
            int passwordLength = txtfldPassword.getText().length();

            // If password length equal to 8 characters, password field will uneditable
            if (passwordLength > 8) {
              txtfldPassword.setEditable(false);
            }
          }
        };

    txtfldPassword.setText("passWord");
    txtfldUserName.setText("User name");
    txtfldPassword.addKeyListener(kl);
    txtfldPassword.addCaretListener(caretListener);

    txtfldUserName.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent fe) {
            txtfldUserName.setText("");
          }

          @Override
          public void focusLost(FocusEvent fe) {
            txtfldPassword.setText("Password");
          }
        });

    txtfldPassword.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent fe) {
            txtfldPassword.setText("");
          }

          @Override
          public void focusLost(FocusEvent fe) {}
        });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                jPanel1,
                javax.swing.GroupLayout.Alignment.TRAILING,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(btnLogIn)
                            .addGroup(
                                layout
                                    .createParallelGroup(
                                        javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(
                                        layout
                                            .createSequentialGroup()
                                            .addComponent(labelPassword)
                                            .addGap(18, 18, 18)
                                            .addComponent(txtfldPassword))
                                    .addGroup(
                                        javax.swing.GroupLayout.Alignment.LEADING,
                                        layout
                                            .createSequentialGroup()
                                            .addComponent(lableUser)
                                            .addGap(18, 18, 18)
                                            .addComponent(
                                                txtfldUserName,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                197,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGap(0, 25, Short.MAX_VALUE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        jPanel1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lableUser)
                            .addComponent(
                                txtfldUserName,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(labelPassword)
                            .addComponent(
                                txtfldPassword,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(btnLogIn)
                    .addContainerGap()));

    txtfldUserName.getAccessibleContext().setAccessibleName("");

    pack();
  } // </editor-fold>
예제 #15
0
 @Override
 public synchronized void addKeyListener(final KeyListener l) {
   renderer.addKeyListener(l);
   editor.addKeyListener(l);
 }
  public void LoginKeyListener(final JTabbedPane tab, final JPanel c) {
    Password.addKeyListener(
        new KeyListener() {

          @Override
          public void keyPressed(KeyEvent arg0) {
            // TODO Auto-generated method stub
            if (arg0.getKeyCode() == 10) {
              String username = UserName.getText();
              String password = new String(Password.getPassword());

              if (username.isEmpty() || password.isEmpty()) {
                JOptionPane.showMessageDialog(card, "Staff ID and Password has to be filled ");
                UserName.setText("");
                Password.setText("");
              } else if (!isInteger(username)) {
                JOptionPane.showMessageDialog(card, "Staff ID is not a number ");
                UserName.setText("");
                Password.setText("");
              } else {
                // check if the ID exist
                if (!processLogin(username, password)) {
                  JOptionPane.showMessageDialog(card, "Wrong Staff ID or Password ");
                  Password.setText("");
                } else {
                  // sql to update database for when someone is logged in
                  String sql =
                      "UPDATE admin_login SET isLogedin = '1' WHERE staff_id = '" + username + "'";

                  try {
                    // execute statement
                    db.ExecuteStatement(sql);

                    // disable logIn button when someone is logged in
                    LogIn.setEnabled(false);
                    Logout.setEnabled(true);

                    // show a message that login was successful
                    JOptionPane.showMessageDialog(card, "Welcome!! ");

                    LoginName.setText(username);
                    LoginLabel.setForeground(Color.GREEN);

                    // Reset staff id and password here
                    UserName.setText("");
                    Password.setText("");

                    // Open Navigation tab
                    tab.add("NAVIGATION PAGE", c);
                    tab.setSelectedComponent(c);

                    resetPassword.setEnabled(false);

                  } catch (SQLException e1) {

                    e1.printStackTrace();
                  }
                }
              }
            }
          }

          @Override
          public void keyReleased(KeyEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void keyTyped(KeyEvent arg0) {
            // TODO Auto-generated method stub

          }
        });
  }
예제 #17
0
  public LoginPanel(final Controller controller) {
    super(controller);
    setLayout(null);
    Font font = new Font("Tahoma", Font.PLAIN, 28);
    Font font2 = new Font("Tahoma", Font.PLAIN, 16);

    // Welcome Label
    JLabel welcomeLabel = new JLabel("Herzlich Willkommen bei ShareBoxUltimate");
    welcomeLabel.setFont(font);
    welcomeLabel.setBounds(42, 11, 620, 91);
    add(welcomeLabel);

    // label statement - what the user have to do
    JLabel loginLabel = new JLabel("Bitte loggen Sie sich ein:");
    loginLabel.setBounds(212, 108, 298, 67);
    loginLabel.setFont(font2);
    add(loginLabel);

    // label statement for registration
    JLabel lblNochKeinLogin = new JLabel("Noch kein Login? Dann melden Sie sich jetzt an:");
    lblNochKeinLogin.setBounds(134, 446, 376, 34);
    lblNochKeinLogin.setFont(font2);
    add(lblNochKeinLogin);

    // text field userName
    final JTextField loginNameField = new JTextField("username");
    loginNameField.addFocusListener(
        new FocusAdapter() {
          @Override
          // is clearing the field for Users Input
          public void focusGained(FocusEvent arg0) {
            loginNameField.setText("");
          }
        });

    // create the statement to put in user name
    loginNameField.setToolTipText("Bitte geben Sie hier ihren Benutzernamen ein");
    loginNameField.setBounds(190, 204, 110, 50);
    add(loginNameField);
    loginNameField.setFont(font2);

    // label text is only shown if login data is invalid
    final JLabel loginFailedLabel = new JLabel("");
    loginFailedLabel.setBounds(239, 157, 300, 50);
    loginFailedLabel.setFont(font2);
    loginFailedLabel.setForeground(Color.red);
    add(loginFailedLabel);

    // text field password
    final JPasswordField loginPasswordField = new JPasswordField("password");
    loginPasswordField.addFocusListener(
        new FocusAdapter() {
          @Override
          // is clearing the field for Users Input
          public void focusGained(FocusEvent arg0) {
            loginPasswordField.setText("");
          }
        });

    // button login and actionHandling
    JButton loginButton = new JButton("Login");
    loginButton.setToolTipText("Hier klicken zum Einloggen");
    loginButton.setBounds(236, 282, 130, 72);
    add(loginButton);
    loginButton.setFont(font2);
    // button is shown after bad login
    final JButton forgottenLogin = new JButton("");
    forgottenLogin.setForeground(Color.RED);
    forgottenLogin.setFont(font2);
    forgottenLogin.setContentAreaFilled(false);
    forgottenLogin.setBounds(190, 375, 220, 51);
    forgottenLogin.setToolTipText(
        "Bitte klicken Sie hier, um ihren Benutzernamen und Passwort zu erfahren");

    // create the statement to put in password
    loginPasswordField.setToolTipText("Bitte geben Sie hier ihr Passwort ein");
    loginPasswordField.addKeyListener(
        new KeyAdapter() {
          @Override
          // login with pressing enter key after password
          public void keyReleased(KeyEvent evnt) {

            if (evnt.getKeyCode() == KeyEvent.VK_ENTER) {

              String name = loginNameField.getText();
              // string constructor - creates string from charArray

              String password = new String(loginPasswordField.getPassword());
              User user = controller.login(name, password);

              if (user != null) {

                login(user);
              } else {
                // show error message
                loginFailedLabel.setText("Falsche Login-Daten");
                add(forgottenLogin);
                forgottenLogin.setVisible(true);
                forgottenLogin.setText("Benutzerdaten vergessen?");

                /** When login failed view change to forgottenLoginPanel */
                final ActionListener forgottenLoginClickedActionListener =
                    new ActionListener() {
                      @Override
                      public void actionPerformed(final ActionEvent evntg) {
                        changePanel(new ForgottenLoginPanel(controller));
                      }
                    };
                forgottenLogin.addActionListener(forgottenLoginClickedActionListener);
                add(forgottenLogin);
              }
            }
          }
        });
    // create password field
    loginPasswordField.setPreferredSize(new Dimension(53, 20));
    loginPasswordField.setBounds(316, 206, 128, 50);
    add(loginPasswordField);
    loginPasswordField.setFont(font2);

    // button register
    JButton registerButton = new JButton("Registrieren");
    registerButton.setToolTipText("Hier klicken, um sich zu registrieren");
    registerButton.setBounds(156, 508, 322, 50);

    // action-handling register button
    ActionListener registerButtonClickedActionListener =
        new ActionListener() {
          @Override
          // change the view when user push the register button
          public void actionPerformed(ActionEvent fevent) {

            changePanel(new RegisterPanel(controller));
          }
        };

    /** Error display is shown, when login button is clicked and user could not found. */
    registerButton.addActionListener(registerButtonClickedActionListener);
    add(registerButton);

    ActionListener loginButtonClickedActionListener =
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent eevent) {
            String name = loginNameField.getText();
            // string constructor - creates a string out of an a charArray

            String password = new String(loginPasswordField.getPassword());
            User user = controller.login(name, password);

            if (user != null) {

              login(user);

            } else {
              // show error message
              loginFailedLabel.setText("Falsche Login-Daten");
              add(forgottenLogin);
              forgottenLogin.setVisible(true);
              forgottenLogin.setText("Benutzerdaten vergessen?");

              final ActionListener forgottenLoginClickedActionListener =
                  new ActionListener() {
                    @Override
                    // change the view when user push the register button
                    public void actionPerformed(final ActionEvent evntg) {
                      changePanel(new ForgottenLoginPanel(controller));
                    }
                  };
              forgottenLogin.addActionListener(forgottenLoginClickedActionListener);
              add(forgottenLogin);
            }
          }
        };

    loginButton.addActionListener(loginButtonClickedActionListener);
  }
예제 #18
0
  public LoginPanel(Image img, ActionListener listener) {
    super(null);
    this.listener = listener;
    if (img == null) {
      InputStream inData = getClass().getResourceAsStream("/resources/background.gif");
      BufferedImage back = null;
      if (inData != null)
        try {
          back = ImageIO.read(inData);
        } catch (IOException e) {
          loger.finest("LoginPanel class can't get the background image");
        }
      this.background = back;
    }

    setLayout(null);
    JPanel logingPanel = new JPanel();
    loginTitle = new JLabel("Autentificare");
    logingPanel.setSize(250, 150);
    logingPanel.setBorder(new javax.swing.border.LineBorder(Color.black, 2));
    logingPanel.setLayout(null);
    loginTitle.setBounds(3, 0, logingPanel.getWidth(), 20);
    logingPanel.add(loginTitle);
    JLabel loginUser = new JLabel("Utilizator");
    loginUser.setBounds(
        80 - loginUser.getPreferredSize().width,
        40,
        loginUser.getPreferredSize().width,
        loginUser.getPreferredSize().height);
    logingPanel.add(loginUser);
    user = new JTextField(10);
    user.setBounds(85, 40, user.getPreferredSize().width, user.getPreferredSize().height);
    // user.setText("test");
    // loginUser.setLabelFor(user);
    logingPanel.add(user);
    JLabel loginPass = new JLabel("Parola");
    loginPass.setBounds(
        80 - loginPass.getPreferredSize().width,
        80,
        loginPass.getPreferredSize().width,
        loginPass.getPreferredSize().height);
    logingPanel.add(loginPass);
    // JTextField pass = new JTextField(10);
    pass = new JPasswordField(10);
    pass.setBounds(85, 80, pass.getPreferredSize().width, pass.getPreferredSize().height);
    pass.addKeyListener(this);
    // pass.setText("test");
    // loginUser.setLabelFor(user);
    logingPanel.add(pass);
    JButton loginButton = new JButton("Start");
    loginButton.setActionCommand("LOGIN");
    loginButton.setBounds(
        60, 110, loginButton.getPreferredSize().width, loginButton.getPreferredSize().height);
    // loginButton.setOpaque(false);
    loginButton.setFocusPainted(false);
    // loginButton.setContentAreaFilled(false);
    // loginButton.setBorderPainted(false);
    loginButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    loginButton.addActionListener(listener);
    logingPanel.add(loginButton);

    add(logingPanel);
  }