'Java system trayicon mouselistener
Here is the code. I want to ask why is that mouseClicked for a trayicon works perfectly but mouseEntered won't work at all?
mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
showStage(stage);
EventQueue.invokeLater(new Runnable() {
public void run() {
}
});
}
}
@Override
public void mouseEntered(MouseEvent e) {
// why this cant be triggerd
trayIcon.displayMessage(
"警告", "这是一个警告提示!", TrayIcon.MessageType.WARNING);
}
};
trayIcon.addMouseListener(mouseListener);
Solution 1:[1]
After
trayIcon.addMouseListener(mouseListener);
add this line:
trayIcon.addMouseMotionListener(mouseListener);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Just another Java programmer |
