我有以下问题:我的鼠标输入方法不起作用,我也不知道为什么。按下鼠标可以正常工作,只有mouseEntered不能。
这是鼠标侦听器:
MouseListener mouseListener = new MouseListener() {
public void mouseClicked(MouseEvent e) {
jpopup.setLocation(e.getX(), e.getY());
jpopup.setInvoker(jpopup);
jpopup.setVisible(true);
System.out.println("Tray Icon - Mouse clicked!");
}
@Override
public void mouseEntered(MouseEvent e) {
System.out.println("Tray Icon - Mouse entered!");
}
public void mouseExited(MouseEvent e) {
System.out.println("Tray Icon - Mouse exited!");
}
public void mousePressed(MouseEvent e) {
System.out.println("Tray Icon - Mouse pressed!");
}
public void mouseReleased(MouseEvent e) {
System.out.println("Tray Icon - Mouse released!");
}
};
这里是trayIcon:
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(actionListener);
trayIcon.addMouseListener(mouseListener);
错误在哪里?我不知道...
编辑:我正在使用eclipse,如果那很有趣...
最佳答案