I working on an application in which i using a SystemTray
. Every things is fine in my code. When i click the SystemTray
icon it show my jFrame
in given location. But i want to show my jFrame
just below my SystemTray
icon.
Is this possible. Please suggest some code for it. As i can show it in my OS(linux) by giving right coordinate but my code is get fail if i run this program in different OS or different screen size system.
As far as I know, it is not possible to get the SystemTray icon coordinates on the screen using Swing. Another workaround would be to capture the mouse location when the tray icon is clicked.
Point p = MouseInfo.getPointerInfo().getLocation();
int mouseX = (int) p.getX();
int mouseY = (int) p.getY();
Keep in mind that this solution will not help you if you plan to navigate to the tray icon using your keyboard.