예제 #1
0
  void createGUI() {
    // create username field info
    Box fields = Box.createVerticalBox();
    fields.add(Box.createVerticalStrut(10));
    fields.setOpaque(false);

    JPanel userNameCont = new JPanel(new GridLayout(1, 2));
    JLabel usernameLabel = new JLabel("username ");
    usernameLabel.setFont(UIHelper.VER_12_BOLD);
    usernameLabel.setForeground(UIHelper.DARK_GREEN_COLOR);
    userNameCont.add(usernameLabel);

    username = new RoundedJTextField(10, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR);
    username.setOpaque(false);

    UIHelper.renderComponent(username, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    userNameCont.add(username);
    userNameCont.setOpaque(false);

    JPanel passwordCont = new JPanel(new GridLayout(1, 2));
    JLabel passwordLabel = new JLabel("password ");
    passwordLabel.setFont(UIHelper.VER_12_BOLD);
    passwordLabel.setForeground(UIHelper.DARK_GREEN_COLOR);
    passwordCont.add(passwordLabel);
    password = new RoundedJPasswordField(10, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR);
    UIHelper.renderComponent(password, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    passwordCont.add(password);
    passwordCont.setOpaque(false);

    fields.add(userNameCont);
    fields.add(Box.createVerticalStrut(10));
    fields.add(passwordCont);

    JPanel northPanel = new JPanel();
    northPanel.add(new JLabel(pleaseLogin, JLabel.RIGHT), BorderLayout.NORTH);
    northPanel.add(fields, BorderLayout.CENTER);

    JPanel southPanel = new JPanel(new GridLayout(4, 1));
    southPanel.setOpaque(false);

    JPanel buttonContainer = new JPanel(new GridLayout(1, 2));
    buttonContainer.setOpaque(false);

    createProfile = new JLabel(createProfileButton, JLabel.LEFT);
    createProfile.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            createProfile.setIcon(createProfileButton);

            clearFields();

            confirmExitPanel.setVisible(false);

            menu.changeView(menu.getCreateProfileGUI());
          }

          public void mouseEntered(MouseEvent event) {
            createProfile.setIcon(createProfileButtonOver);
          }

          public void mouseExited(MouseEvent event) {
            createProfile.setIcon(createProfileButton);
          }
        });

    buttonContainer.add(createProfile);

    login = new JLabel(loginButton, JLabel.RIGHT);
    login.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            login.setIcon(Authentication.this.loginButton);
            confirmExitPanel.setVisible(false);
            login();
          }

          public void mouseEntered(MouseEvent event) {
            login.setIcon(loginButtonOver);
          }

          public void mouseExited(MouseEvent event) {
            login.setIcon(Authentication.this.loginButton);
          }
        });

    Action loginAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            login();
          }
        };

    password.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOGIN");
    password.getActionMap().put("LOGIN", loginAction);
    username.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOGIN");
    username.getActionMap().put("LOGIN", loginAction);

    buttonContainer.add(login);

    southPanel.add(status);
    southPanel.add(buttonContainer);

    exit = new JLabel(exitButtonSml, JLabel.CENTER);
    exit.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            exit.setIcon(exitButtonSml);
            confirmExitPanel.setVisible(true);
            confirmExitPanel.getParent().validate();
          }

          public void mouseEntered(MouseEvent event) {
            exit.setIcon(exitButtonSmlOver);
          }

          public void mouseExited(MouseEvent event) {
            exit.setIcon(exitButtonSml);
          }
        });

    JPanel exitCont = new JPanel(new GridLayout(1, 1));
    exitCont.setOpaque(false);

    exitCont.add(exit);

    southPanel.add(exitCont);

    southPanel.add(confirmExitPanel);

    northPanel.add(southPanel, BorderLayout.SOUTH);
    northPanel.setOpaque(false);

    add(northPanel, BorderLayout.CENTER);
  }