title: componentListener getting disabled
body: <p>I have an unusual issue in which a componentListener/Adapter is being disabled whenever the mouseListener/Adapter detects an event.  In the code below, the <code>componentMoved()</code> method override works perfectly until the <code>mouseClicked()</code> method override is triggered in the <code>MouseAdapter()</code>.  Any ideas how to fix this?</p>
  
  <pre><code>public AlertScroller(String msg,Color col) {
      addComponentListener(new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
              setShape(new Rectangle2D.Double(0, 0, getWidth(), newHeight));
              if(!isVisible())
                  setVisible(true);
          }
      });
  
      addMouseListener(new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent click) {
              if(SwingUtilities.isLeftMouseButton(click)) {
                  autoClear = false;
                  scrollOff();
              }
          }
      });
      setAlwaysOnTop(true);
      JPanel panel = new JPanel();
          panel.setBorder(compound);
          panel.setBackground(col);
  
      JLabel imgLbl = new JLabel(msg);
          imgLbl.setFont(new Font("Arial",Font.BOLD,30));
  
      panel.add(imgLbl);
      setContentPane(panel);
      pack();
  }
  </code></pre>
  
  <p>The class that this method is in extends <code>JWindow</code>.</p>
  
  <p>Edit: Added the <code>scrollOff()</code> method's code.</p>
  
  <pre><code>public void scrollOff() {
      Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
      int taskBar = scnMax.bottom;
      int x = screenSize.width - getWidth();
      int yEnd = screenSize.height - taskBar;
      int yStart = this.getBounds().y;
      setLocation(x,yStart);
      int current = yStart;
      newHeight = this.getBounds().height;
      while(current &lt; yEnd) {
          current+=2;
          newHeight = yEnd - current;
          setLocation(x,current);
          try {
              Thread.sleep(30);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
      dispose();
      Main.alertControl.setAlertActive(false);
  }
  </code></pre>
  
  <p>This is basically the exact reverse of the scrollOn() method and works perfectly fine as long as it's triggered by any means other than through the <code>Listener</code>.</p>
  
  <p><strong>Edit 2:</strong> Fixed code below thanks to MadProgrammer's advice</p>
  
  <pre><code>public void scrollOff() {
      x = screenSize.width - getWidth();
      yEnd = screenSize.height - taskBar;
      yStart = this.getBounds().y;
      setLocation(x,yStart);
      current = yStart;
      newHeight = this.getBounds().height;
  
      ActionListener action = new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
              if(current &lt; yEnd) {
                  current+=2;
                  newHeight = yEnd - current;
                  setLocation(x,current);
              } else {
                  timer.stop();
              }
          }
      };
  
      timer = new Timer(30, action);
      timer.setInitialDelay(0);
      timer.start();
      Main.alertControl.setAlertActive(false);
  }
  </code></pre>
  
  <p>I also updated the <code>AlertScroller()</code> constructor method with an <code>else if</code> to hide the window properly when I'm done:</p>
  
  <pre><code>    addComponentListener(new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
              setShape(new Rectangle2D.Double(0, 0, getWidth(), newHeight));
              if(!isVisible())
                  setVisible(true);
              else if(getBounds().y == screenSize.height - taskBar)
                  setVisible(false);
          }
      });
  </code></pre>
  
  <p>Placing <code>setVisible(false)</code> anywhere else caused the window to become visible again.</p>