我有以下问题:我的鼠标输入方法不起作用,我不知道为什么。按下的鼠标效果很好,只有 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.setImageAutoSize(true);
trayIcon.addActionListener(actionListener);
trayIcon.addMouseListener(mouseListener);
错误在哪里?我不知道...
编辑:我正在使用 eclipse,如果这很有趣......