title: MouseListener & MouseMotionListener don't work for JPanel with JComponents inside
body: <p>I'm trying to drag JComponents which are inside a JPanel on a JFrame or better on the rootPane of the JFrame.</p>
  <p>The JPanel which contains the components is using a horizontal BoxLayout.</p>
  <p>When I run the code below I observed the following issues:</p>
  <ol>
  <li>The MouseListener &amp; MouseMotionListener are only working for the JLabel</li>
  <li>The JLabel seems to be not visible</li>
  <li>On trying to drag, the JPanel with the JComponents inside the JTextfield &amp; JButton disapper once I hover over the location where the JButton was dragged it becomes visible again.</li>
  </ol>
  <p>What am I doing wrong here? Such a little code and so many unexpected issues.</p>
  <p>Please help!</p>
  <p>Code to reproduce the issues:</p>
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.MouseEvent;
  import java.awt.event.MouseListener;
  import java.awt.event.MouseMotionListener;
  
  public class Main extends JFrame implements MouseListener, MouseMotionListener {
      private volatile int screenX = 0;
      private volatile int screenY = 0;
      private volatile int myX = 0;
      private volatile int myY = 0;
      private JPanel myPane;
  
  public Main() {
      setSize(500,500);
      myPane = new JPanel();
      //myPane.setLayout(new BoxLayout(myPane, BoxLayout.X_AXIS));
  
      JTextField tf = new JTextField(&quot;Some text&quot;);
      tf.setEnabled(false);
      tf.setSize(110,20);
      JLabel l = new JLabel(&quot;°C&quot;);
      l.setSize(40,20);
      JButton b = new JButton(&quot;Button&quot;);
  
      myPane.setSize(new Dimension(tf.getWidth()+l.getWidth(), tf.getHeight()));
  
      myPane.add(tf);
      myPane.add(l);
      myPane.add(b);
      rootPane.add(myPane);
  
      myPane.addMouseListener(this);
      myPane.addMouseMotionListener(this);
  }
  public static void main(String[] args) {
      Main f = new Main();
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.setVisible(true);
  }
  
  @Override
  public void mouseClicked(MouseEvent e) {
  
  }
  
  @Override
  public void mousePressed(MouseEvent e) {
      screenX = e.getXOnScreen();
      screenY = e.getYOnScreen();
      myX = myPane.getX();
      myY = myPane.getY();
  }
  
  @Override
  public void mouseReleased(MouseEvent e) {
  
  }
  
  @Override
  public void mouseEntered(MouseEvent e) {
      System.out.println(&quot;Entered&quot;);
  }
  
  @Override
  public void mouseExited(MouseEvent e) {
  
  }
  
  @Override
  public void mouseDragged(MouseEvent e) {
      // only move when edit mode selected
      System.out.println(&quot;Dragged&quot;);
      int deltaX = e.getXOnScreen() - screenX;
      int deltaY = e.getYOnScreen() - screenY;
  
      myPane.setLocation(myX + deltaX, myY + deltaY);
  
      revalidate();
  }
  
  @Override
  public void mouseMoved(MouseEvent e) {
  
  }
  }
  </code></pre>