1. The following toy code is OK:
public class XXX extends JPanel implements MouseMotionListener{
JButton jButton = new jButton("Test");
jButton.addMouseMotionListener(this);
public void mouseDrapped(MouseEvent e){
//Do this
}
public void mouseMoved9MouseEvent e){
//Do that
}
}
Comments: "JButton.this" is at least a poor syntax.
2. In Java gragramming, it is a common practice to have a Container be an EventListener. But it is not a good idea to let Button or JButton be a listener. Academically, it is OK.
public class XXX extends JPanel implements MouseMotionListener{
JButton jButton = new jButton("Test");
jButton.addMouseMotionListener(this);
public void mouseDrapped(MouseEvent e){
//Do this
}
public void mouseMoved9MouseEvent e){
//Do that
}
}
Comments: "JButton.this" is at least a poor syntax.
2. In Java gragramming, it is a common practice to have a Container be an EventListener. But it is not a good idea to let Button or JButton be a listener. Academically, it is OK.