如何在JPanel中同时处理鼠标和键监听器? 我尝试添加混合侦听器,并设置JPanel的setFocusable(true):
class MyListener implements MouseListener, KeyListener {
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void keyTyped(KeyEvent e) {}
public void keyPressed(KeyEvent e) {}
public void keyReleased(KeyEvent e) {}
}
但是当按下键时,鼠标监听器不会听动作,如何处理?