title: mouseMoved Event can't get location of cursor
body: <p>newbie in here</p>
  
  <p>this is my code and i wanna when cursor get into green jpanel (here is "p2"), program will have another jpanel (here is "p1") to show some information about Object. (like a ToolTip)</p>
  
  <p>But when cursor get into JPanel p2 ... mouseMove can't get location of the cursor ... It only work when I remove JPanel p2 . Please help me guys </p>
  
  <p>Note: It's still work on border of JPanel p2;<div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import javax.management.Attribute;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.ImageIcon;
  import javax.swing.JTextPane;
  import javax.swing.border.EmptyBorder;
  import javax.swing.text.AttributeSet.FontAttribute;
  
  import org.w3c.dom.events.EventTarget;
  import org.w3c.dom.events.MouseEvent;
  import org.w3c.dom.views.AbstractView;
  
  import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Dimension;
  import java.awt.EventQueue;
  import java.awt.FlowLayout;
  import java.awt.Font;
  import java.awt.Graphics;
  import java.awt.GridLayout;
  import java.awt.Image;
  import java.awt.MouseInfo;
  import java.awt.Rectangle;
  import java.awt.event.MouseAdapter;
  import java.awt.event.MouseListener;
  import java.awt.event.MouseMotionListener;
  import java.text.AttributedCharacterIterator;
  import java.util.Locale;
  
  public class InterfaceSubject extends JFrame {
  
   public JPanel contentPane, p1, p2;
   public JButton bt1;
   public JLabel lb2;
   public JTextPane tp1, tp2, tp3;
  
   public InterfaceSubject() {
    this.setResizable(false);
    setTitle("Demo");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setBounds(100, 20, 1024, 768);
  
    bt1 = new JButton();
    p1 = new JPanel();
    p1.setLayout(new BorderLayout());
          p1.setBackground(Color.yellow);
  
  
    p2 = new JPanel();
    GridLayout gr = new GridLayout();
    gr.setColumns(1);
    gr.setRows(3);
    p2.setLayout(gr);
  
    lb2 = new JLabel();
  
    tp1 = new JTextPane();
    tp1.setForeground(Color.BLUE);
    tp1.setBackground(Color.green);
    tp1.setText("MMH: 212121");
  
    tp2 = new JTextPane();
    tp2.setForeground(Color.BLUE);
    tp2.setBackground(Color.green);
    tp2.setText("Tên MH: Hello");
  
    tp3 = new JTextPane();
    tp3.setForeground(Color.BLUE);
    tp3.setBackground(Color.green);
    tp3.setText("TC : 1");
  
    contentPane = new ImagePanel(
      new ImageIcon("images\\formtkb.jpg").getImage());
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  
    p2.setBounds(60, 121, 125, 75);
  
    p2.add(tp1);
    p2.add(tp2);
    p2.add(tp3);
  
    contentPane.add(p2);
  
    setContentPane(contentPane);
  
    contentPane.setLayout(null);
  
    this.addMouseMotionListener(new MouseMotionListener() {
  
     @Override
     public void mouseMoved(java.awt.event.MouseEvent arg0) {
  
      if ((arg0.getX()) &gt;= (60) &amp;&amp; arg0.getX() &lt;= (60 + 125)) {
       if ((arg0.getY()) &gt;= (121 + 25)
         &amp;&amp; (arg0.getY()) &lt;= (121 + 100)) {
        p1.setVisible(true);
        p1.setBounds(new Rectangle(arg0.getPoint(),
          new Dimension(200, 200)));
        lb2.setText(arg0.getX() + " / " + arg0.getY());
  
        p1.add(lb2, BorderLayout.SOUTH);
        contentPane.add(p1);
       } else {
        p1.setVisible(false);
       }
      } else {
       p1.setVisible(false);
      }
  
     }
  
     @Override
     public void mouseDragged(java.awt.event.MouseEvent arg0) {
      // TODO Auto-generated method stub
  
     }
    });
  
   }
  
  }
  
  class ImagePanel extends JPanel {
  
   /**
     * 
     */
   private Image img;
  
   public ImagePanel(String img) {
    this(new ImageIcon(img).getImage());
   }
  
   public ImagePanel(Image img) {
    this.img = img;
    Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
    setPreferredSize(size);
    setMinimumSize(size);
    setMaximumSize(size);
    setSize(size);
    setLayout(null);
  
   }
  
   public void paintComponent(Graphics g) {
    g.drawImage(img, 0, 100, null);
   }
  
  }</code></pre>
  </div>
  </div>
  </p>