Skip to content

Instantly share code, notes, and snippets.

@dustinkredmond
Created September 22, 2021 01:54
Show Gist options
  • Save dustinkredmond/e1e59786ab50537d6868feaf5238c58b to your computer and use it in GitHub Desktop.
Save dustinkredmond/e1e59786ab50537d6868feaf5238c58b to your computer and use it in GitHub Desktop.
Minimize window and allow FXTrayIcon to exist in system tray
package test;
import com.dustinredmond.fxtrayicon.FXTrayIcon;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class App extends Application {
@Override
public void start(Stage stage) throws Exception {
FXTrayIcon icon = new FXTrayIcon(stage, getClass().getResource("image.png"));
icon.show();
GridPane grid = new GridPane();
Button button = new Button("Minimize Icon");
button.setOnAction(e -> stage.hide());
stage.setScene(new Scene(grid));
stage.show();
}
public static void main(String[] args) {
Application.launch(App.class, args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment