Scroll through a List of multiple JPanels Java

I am coding a nearly finished Password manager. My only problem I have is the scrolling. When I add a User to my List, I am creating a Jpanel+2 JLabels. I want to be able to scroll through my list of them.

        public void mouseWheelMoved(MouseWheelEvent e)
          {
            if ((e.getX() > 645) && (e.getX() < 1280))
            {
              int y;
              if (e.getWheelRotation() < 0)
              {
                for (JPanel p : Main.elements)
                {
                  int y = p.getY();
                  if (p == Main.elements.get(0)) {
                    if (Math.max(p.getY(), 60) == p.getY()) {
                      Main.isstuck_panel = true;
                    } else {
                      Main.isstuck_panel = false;
                    }
                  }
                  if (!Main.isstuck_panel) {
                    p.setLocation(p.getX(), p.getY() + e.getScrollAmount() * 2);
                  }
                }
                for (JLabel p : Main.elements_)
                {
                  int y = p.getY();
                  if (p == Main.elements_.get(0)) {
                    if (Math.max(p.getY(), 80) == p.getY()) {
                      Main.isstuck_labelemail = true;
                    } else {
                      Main.isstuck_labelemail = false;
                    }
                  }
                  if (!Main.isstuck_labelemail) {
                    p.setLocation(p.getX(), p.getY() + e.getScrollAmount() * 2);
                  }
                }
                for (JLabel p : Main.elements__)
                {
                  y = p.getY();
                  if (p == Main.elements__.get(0)) {
                    if (Math.max(p.getY(), 60) == p.getY()) {
                      Main.isstuck_labeluser = true;
                    } else {
                      Main.isstuck_labeluser = false;
                    }
                  }
                  if (!Main.isstuck_labeluser) {
                    p.setLocation(p.getX(), p.getY() + e.getScrollAmount() * 2);
                  }
                }
              }
              else
              {
                int x = 0;
                for (JPanel p : Main.elements)
                {
                  int y = p.getY();
                  if (Main.elements.indexOf(p) == Main.elements.size() - 1) {
                    if (Math.min(p.getY() + p.getHeight(), Main.frame.getHeight()) == p.getY() + p.getHeight()) {
                      Main.isstuck_panel = true;
                    } else {
                      Main.isstuck_panel = false;
                    }
                  }
                  if (Main.isstuck_panel) {
                    for (int i = Math.min(p.getY() + 40, Main.frame.getHeight()); i == p.getY() + 40; i++) {
                      p.setLocation(p.getX(), i);
                    }
                  } else {
                    p.setLocation(p.getX(), p.getY() - e.getScrollAmount());
                  }
                  x++;
                }
                for (JLabel p : Main.elements_)
                {
                  int y = p.getY();
                  if (Main.elements_.indexOf(p) == Main.elements_.size() - 1) {
                    if (Math.min(p.getY() - 20 + 40, Main.frame.getHeight()) == p.getY() - 20 + 40) {
                      Main.isstuck_labeluser = true;
                    } else {
                      Main.isstuck_labeluser = false;
                    }
                  }
                  if (Main.isstuck_labeluser) {
                    for (int i = Math.min(p.getY() - 20 + 40, Main.frame.getHeight()); i == p.getY() + 40; i++) {
                      p.setLocation(p.getX(), i);
                    }
                  } else {
                    p.setLocation(p.getX(), p.getY() - e.getScrollAmount());
                  }
                }
                for (JLabel p : Main.elements__)
                {
                  int y = p.getY();
                  if (Main.elements__.indexOf(p) == Main.elements__.size() - 1) {
                    if (Math.min(p.getY() + 40, Main.frame.getHeight()) == p.getY() + 40) {
                      Main.isstuck_labelemail = true;
                    } else {
                      Main.isstuck_labelemail = false;
                    }
                  }
                  if (Main.isstuck_labelemail) {
                    for (int i = Math.min(p.getY() + 40, Main.frame.getHeight()); i == p.getY() + 40; i++) {
                      p.setLocation(p.getX(), i);
                    }
                  } else {
                    p.setLocation(p.getX(), p.getY() - e.getScrollAmount());
                  }
                }
              }
            }
          }

I know this is not the best way to do it, but it worked. But I ran into one bug: I have 20 Users, but I can only scroll to the 19th.