Ejemplo n.º 1
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();
    }
  }
Ejemplo n.º 2
0
 void deleteButton_actionPerformed(ActionEvent e) {
   int row = table.getSelectedRow();
   if (row != -1) {
     String accountname = (String) usermodel.getValueAt(row, 0);
     usermodel.removeUser(accountname);
     usermodel.fireTableDataChanged();
   }
 }
Ejemplo n.º 3
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);
  }