title: item from arrayList deletes from panel but not from actual arrayList?
body: <p>Previously I wrote a program that would add users then make a list with checkboxes next to the user's names and then you would be able to select from it and press delete button to delete the user's name along with the checkbox next to it. <strong>Now after building and putting together my actual program I realized that the names actually do not delete from the actual list but only from the panel (therefore it just turns invisible). How can I make it so that it actually deletes from the arraylist and not just the panel? Also is there a way to make it so that it doesn't accept the same user name?</strong> </p>
  
  <p>My complete codes for the program is located here: <a href="https://github.com/76342ck/CHORE-SCORE" rel="nofollow">GITHUB</a></p>
  
  <p>In here when I run the MenuWindow and click on Manage Users my ManageUsersGUI window pops up and it lets me add and delete users. When i close it and press on View Available Chores it opens another window in which it allows me to view chores from a user which i can select from a JComboBox. But it shows all the same repeated names and the names that i deleted. If i go back and press the Manage Users button the window pops up again and has no list of Users from before. It's empty again and if you add the same names it will let you add and again and when you delete it doesn't actually delete.</p>
  
  <p>Here's my code for ManageUsersGUI:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  import java.util.ArrayList;
  import javax.swing.JCheckBox;
  
  public class ManageUsersGUI extends JFrame {
      public ArrayList&lt;User&gt; users;
      private JLabel title;
      private JLabel addNewUserLabel;
      private JTextField addNewUserTextField;
      private JLabel deleteUsersLabel;
      private JButton addButton;
      private JButton deleteButton;
      private JPanel namePanel;
      final int WINDOW_WIDTH = 500;
      final int WINDOW_HEIGHT = 400;
  
  
      public ManageUsersGUI() {
          setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
  
          //construct components
          title = new JLabel ("Manage Users");
          title.setFont(new Font("Serif", Font.PLAIN, 28));
  
          addNewUserLabel = new JLabel ("Add new User here:");
          addNewUserTextField = new JTextField (0);
          deleteUsersLabel = new JLabel ("Select which User(s) you would like to delete:");
          addButton = new JButton ("Add");
          deleteButton = new JButton ("Delete");
          namePanel = new JPanel();
          namePanel.setLayout(new BoxLayout(namePanel, BoxLayout.Y_AXIS));
  
          //set components properties
          addNewUserTextField.setToolTipText ("Enter name and click on Add button.");
          addButton.setToolTipText ("Click here to Add new user.");
          deleteButton.setToolTipText ("Click here to delete User(s) selected.");
  
          //adjust size and set layout
          setPreferredSize (new Dimension (500, 600));
          setLayout (null);
  
          //add components
          add (title);
          add (addNewUserLabel);
          add (addNewUserTextField);
          add (deleteUsersLabel);
          add (namePanel);
          add (addButton);
          add (deleteButton);
  
          //set component bounds (only needed by Absolute Positioning)
          title.setBounds (170, 10, 300, 100);
          addNewUserLabel.setBounds (65, 90, 120, 25);
          addNewUserTextField.setBounds (200, 90, 125, 25);
          deleteUsersLabel.setBounds (135, 120, 281, 25);
          addButton.setBounds (350, 90, 90, 25);
          namePanel.setBounds(225, 270, 140, 0);
          deleteButton.setBounds (200, 300, 100, 25);
  
          addButton.addActionListener(new AddButtonListener());
  
          deleteButton.addActionListener(new DeleteButtonListener());
  
          setVisible(true);
      }      
  
      private class AddButtonListener implements ActionListener {
          public void actionPerformed(ActionEvent e) {
              String text = addNewUserTextField.getText();
              ChoreScoreData.getUserList().add(new User(text));
  
              // Display the changes.
              JOptionPane.showMessageDialog(null, text + " has been added.");
  
              JCheckBox nameCheckBox = new JCheckBox();
              nameCheckBox.setText(addNewUserTextField.getText());
              namePanel.add(nameCheckBox);
              namePanel.setBounds(225, 140, 140, namePanel.getHeight() + 25);
              deleteButton.setBounds(200, deleteButton.getY() + 25, 100, 25);
              JFrame frame = (JFrame) getRootPane().getParent();
              frame.setSize(frame.getWidth(), frame.getHeight() + 25);
              frame.pack(); 
          }
      }
  
      private class DeleteButtonListener implements ActionListener {
           @Override
           public void actionPerformed(ActionEvent e) {
              for(Component component : namePanel.getComponents()) {
                 if(component instanceof JCheckBox) {
                    if(((JCheckBox)component).isSelected())
                       namePanel.remove(component);
                       for (User user: users) {
                         users.remove(user);
                       }
              }
              namePanel.revalidate();
              namePanel.repaint();
           }   
      }
  
      public static void main (String[] args) {
          JFrame frame = new JFrame ("AddUsersPanel1");
          frame.setTitle("Manage Users");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().add (new ManageUsersGUI());
          frame.pack();
          frame.setVisible (true);
      }
  }
  </code></pre>
  
  <p><strong>UPDATE#2:</strong> Added code to remove from arrayList</p>
  
  <pre><code> private class DeleteButtonListener implements ActionListener {
       @Override
       public void actionPerformed(ActionEvent e) {
          for(Component component : namePanel.getComponents()) {
             if(component instanceof JCheckBox) {
                if(((JCheckBox)component).isSelected())
                   namePanel.remove(component);
                   for (Iterator it = users.iterator(); it.hasNext();) {
                       it.next();
                       it.remove();
                   }           
             }
          }
          namePanel.revalidate();
          namePanel.repaint();
       }   
  }
  </code></pre>
  
  <p>Now gives me this long error:</p>
  
  <pre><code>         ----jGRASP exec: java MenuWindow
  
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at ManageUsersGUI$DeleteButtonListener.actionPerformed(ManageUsersGUI.java:96)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
      at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
      at java.awt.Component.processMouseEvent(Component.java:6525)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3322)
      at java.awt.Component.processEvent(Component.java:6290)
      at java.awt.Container.processEvent(Container.java:2234)
      at java.awt.Component.dispatchEventImpl(Component.java:4881)
      at java.awt.Container.dispatchEventImpl(Container.java:2292)
      at java.awt.Component.dispatchEvent(Component.java:4703)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
      at java.awt.Container.dispatchEventImpl(Container.java:2278)
      at java.awt.Window.dispatchEventImpl(Window.java:2739)
      at java.awt.Component.dispatchEvent(Component.java:4703)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:702)
      at java.awt.EventQueue$3.run(EventQueue.java:696)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
      at java.awt.EventQueue$4.run(EventQueue.java:724)
      at java.awt.EventQueue$4.run(EventQueue.java:722)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
  
   ----jGRASP: operation complete.
  </code></pre>