Пример #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();
    }
  }
Пример #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();
   }
 }