次のコードで mousedragged が認識されない理由を教えてください。この問題を解決するのに役立つ可能性がありますか?
public class Hello extends JPanel implements KeyListener, MouseListener, MouseMotionListener{
JPanel panel = new JPanel();
JFrame frame = new JFrame();
public Hello() {
addKeyListener(this);
addMouseListener(this);
addMouseMotionListener(this);
panel.addKeyListener(this);
panel.addMouseListener(this);
frame.addKeyListener(this);
frame.addMouseListener(this);
}
public static void main(String [] args){
Hello play = new Hello();
play.setPanel();
}
public void setPanel(){
panel.setLayout(null);
frame.add(panel);
frame.setLayout(null);
panel.setBounds(0,0,100,100);
frame.setVisible(true);
panel.setVisible(true);
panel.setFocusable(true);
frame.setSize(100,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void keyTyped(KeyEvent arg0){
System.out.println("keytyped");
}
public void keyPressed(KeyEvent arg0){
System.out.print("keypressed");
}
public void keyReleased(KeyEvent arg0){
System.out.println("keyreleased");
}
public void mousePressed(MouseEvent arg0){
System.out.println("mousepressed");
}
public void mouseReleased(MouseEvent arg0){
System.out.println("mousereleased");
}
public void mouseClicked(MouseEvent arg0){
System.out.println("mouseclicked");
}
public void mouseEntered(MouseEvent arg0){
System.out.println("mousenentered");
}
public void mouseExited(MouseEvent arg0){
System.out.println("mouseexited");
}
public void mouseDragged(MouseEvent arg0){
System.out.println("mousedragged");
}