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();
    }
  }
 private void jbInit() throws Exception {
   titledBorder1 =
       new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "New User");
   titledBorder2 =
       new TitledBorder(
           BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "User accounts");
   this.setLayout(borderLayout1);
   jPanelNewUser.setBorder(titledBorder1);
   jPanelNewUser.setLayout(gridBagLayout1);
   jLabel1.setText("Account name: ");
   jTextFieldAccountname.setColumns(10);
   jLabel2.setText("Password: "******"Repeat Password: "******"Full name: ");
   jTextFieldFullname.setColumns(20);
   addButton.setText("Add");
   addButton.addActionListener(
       new charva.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           addButton_actionPerformed(e);
         }
       });
   jPanel1.setLayout(gridBagLayout2);
   deleteButton.setText("Delete");
   deleteButton.addActionListener(
       new charva.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           deleteButton_actionPerformed(e);
         }
       });
   jPanel1.setBorder(titledBorder2);
   this.add(jPanelNewUser, BorderLayout.NORTH);
   jPanelNewUser.add(
       jLabel1,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.EAST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelNewUser.add(
       jTextFieldAccountname,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelNewUser.add(
       jLabel4,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.EAST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelNewUser.add(
       jTextFieldFullname,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelNewUser.add(
       jLabel2,
       new GridBagConstraints(
           0,
           2,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.EAST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelNewUser.add(
       jPasswordField1,
       new GridBagConstraints(
           1,
           2,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelNewUser.add(
       jLabel3,
       new GridBagConstraints(
           0,
           3,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.EAST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelNewUser.add(
       jPasswordField2,
       new GridBagConstraints(
           1,
           3,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelNewUser.add(
       addButton,
       new GridBagConstraints(
           0,
           4,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   this.add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(
       jPanelUsers,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           100.0,
           100.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel1.add(
       deleteButton,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           10.0,
           10.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
 }
示例#3
0
 private void jbInit() throws Exception {
   border1 = BorderFactory.createLineBorder(Color.black, 2);
   titledBorder1 = new TitledBorder(border1, "Domain-specific settings");
   titledBorder2 =
       new TitledBorder(
           BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Default policy");
   titledBorder3 =
       new TitledBorder(
           BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Domain policy");
   jCheckBoxEnableCookies.setText("Enable Cookies");
   this.setLayout(gridBagLayout1);
   jPanelDomainSpecific.setBorder(titledBorder1);
   jRadioButtonDefaultReject.setText("Reject");
   jRadioButtonDefaultAsk.setText("Ask");
   jPanelDefaultPolicy.setBorder(titledBorder2);
   jPanelDomainPolicy.setBorder(titledBorder3);
   jPanelDomainPolicy.setLayout(borderLayout1);
   jRadioButtonDefaultAccept.setSelected(true);
   jRadioButtonDefaultAccept.setText("Accept");
   jRadioButtonDomainReject.setText("Reject");
   jRadioButtonDomainAsk.setText("Ask");
   jRadioButtonDomainAccept.setSelected(true);
   jRadioButtonDomainAccept.setText("Accept");
   jButtonDelete.setText("Delete");
   jButtonChange.setText("Change");
   jTextField1.setColumns(20);
   jLabel1.setText("Domain: ");
   jPanelDomain.setLayout(flowLayout1);
   flowLayout1.setAlignment(FlowLayout.LEFT);
   this.add(
       jCheckBoxEnableCookies,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           20.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   this.add(
       jPanelDomainSpecific,
       new GridBagConstraints(
           0,
           1,
           2,
           2,
           100.0,
           100.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(0, 0, 0, 0),
           0,
           0));
   this.add(
       jPanelDefaultPolicy,
       new GridBagConstraints(
           2,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelDefaultPolicy.add(jRadioButtonDefaultAccept, null);
   jPanelDefaultPolicy.add(jRadioButtonDefaultAsk, null);
   jPanelDefaultPolicy.add(jRadioButtonDefaultReject, null);
   this.add(
       jPanelDomainPolicy,
       new GridBagConstraints(
           2,
           2,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.NORTHWEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanelDomainPolicy.add(jPanelRadioButtons, BorderLayout.CENTER);
   jPanelRadioButtons.add(jRadioButtonDomainAccept, null);
   jPanelRadioButtons.add(jRadioButtonDomainAsk, null);
   jPanelRadioButtons.add(jRadioButtonDomainReject, null);
   jPanelDomainPolicy.add(jPanelButtons, BorderLayout.SOUTH);
   jPanelButtons.add(jButtonChange, null);
   jPanelButtons.add(jButtonDelete, null);
   jPanelDomainPolicy.add(jPanelDomain, BorderLayout.NORTH);
   jPanelDomain.add(jLabel1, null);
   jPanelDomain.add(jTextField1, null);
 }