Closed pradeepsimba closed 1 year ago
@Jeevasimba What do you mean when you say "tray closing system" ?
I use FXTrayIcon in Java Mac apps all the time and it works beautifully ... better than it does in Windows in my humble opinion.
will it work on linux ?
@Jeevasimba - if your desktop environment supports JavaFX in the system tray, then it will. I think there is an add-on you can get for Gnome that will support it, but I haven't played with it much in Linux.
@Jeevasimba This link might be of some interest to you...
I am using Style.UNDECORATED in my javafx application.
In button I set code like this
public void exit(ActionEvent event){
System.exit(0);
}
If I click that button the tray also closes.
I want to set if I click then the app will go to tray.
How can I set like that with Style.UNDECORATED ?
@Jeevasimba - First of all, when you instantiate FXTrayIcon, you need to pass in the primaryStage that is created from your Main class
@Override public void start(Stage primaryStage) throws Exception {
FXTrayIcon trayIcon = new FXTrayIcon.Builder(primaryStage).build();
}
Of course you can also include any of your custom build options in that sentence such as your chosen icon, and your menuItems etc.
When your menuItems call up other windows, they need to have their own Stage associated with their given Scene. Then, when you need to close that window, just call the .close()
method for that Stage
myStage.close();
@Jeevasimba - You can look at this library that I wrote, that makes managing Java Scenes a little easier. With that library, you assign names to your scenes so that you can access them from anywhere in your application. The library lets you create and show a Scene in one line of code, which you can access from anywhere in your program in any class ... closing a Scene is done like this
SceneOne.close("MySceneId");
The library takes all of the minutiae out of managing scenes.
I set my image as icon.
my image quality is very high
but , in tray the image quality is very low and pixels broken.
I want to set my image as icon with high quality. How can I do this?
@Jeevasimba
You can use a high quality .png file as your image. Look at the images in the resources folder in the project for some examples. like this one for example. However, in Windows, your image size typically can't be greater than 17 x 17 pixels and usually it needs to be 16 x 16 pixels. On a Mac, you can set it to 22 x 22 pixels and it will look really nice on the mac ... here are some that I use on personal programs that I wrote that run on my mac:
If you save that image to your hard drive, then open it and set your zoom to 100%, you'll have a better idea of what they actually look like.
I have a doubt .
Will tray closing system works on linux and mac ?