Пример #1
0
  public AccountPanel() {
    try {
      jbInit();
    } catch (Exception e) {
      e.printStackTrace();
    }

    usermodel.addUser(new User("karl", "Karl Marx", ("rabid#communist").toCharArray()));
    usermodel.addUser(new User("vlad", "Vladimir Lenin", ("looney").toCharArray()));
    table = new JTable(usermodel);
    table.setPreferredScrollableViewportSize(new Dimension(28, 8));
    JScrollPane scrollpane = new JScrollPane(table);
    jPanelUsers.add(scrollpane);
  }
Пример #2
0
  void addButton_actionPerformed(ActionEvent e) {
    if (jTextFieldAccountname.getText().length() == 0) {
      JOptionPane.showMessageDialog(
          null, "Fill in the Account Name", "Error", JOptionPane.ERROR_MESSAGE);
      jTextFieldAccountname.requestFocus();
    } else if (jTextFieldFullname.getText().length() == 0) {
      JOptionPane.showMessageDialog(
          null, "Fill in the Full Name", "Error", JOptionPane.ERROR_MESSAGE);
      jTextFieldFullname.requestFocus();
    } else if ((String.valueOf(jPasswordField1.getPassword()))
            .equals(String.valueOf(jPasswordField2.getPassword()))
        == false) {

      JOptionPane.showMessageDialog(
          null, "Passwords don't match", "Error", JOptionPane.ERROR_MESSAGE);
      jPasswordField1.requestFocus();
    } else {
      usermodel.addUser(
          new User(
              jTextFieldAccountname.getText(),
              jTextFieldFullname.getText(),
              jPasswordField1.getPassword()));
      usermodel.fireTableDataChanged();
    }
  }