0

Suppose I have a class that extends the Application class, as so. (This is an example of a Web Browser implementation I have found from another post)

public class WebViewBrowser extends Application {
    @Override
    public void start(Stage stage) throws Exception {
        stage.setScene(new Scene(new WebViewPane("http://google.com")));
        stage.setFullScreen(true);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

class WebViewPane extends Pane {
    final WebView view = new WebView();
    final Button goButton = createGoButton(view.getEngine());

    public WebViewPane(String initURL) {
        view.getEngine().load(initURL);

        getChildren().addAll(view, goButton);

        initLayout();
    }

    private Button createGoButton(final WebEngine eng) {
        Button go = new Button("Refresh");
        go.setDefaultButton(true);
        go.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                eng.reload();
            }
        });

        return go;
    }

    private void initLayout() {
        setMinSize(500, 400);
        setPrefSize(1024, 768);

        view.prefWidthProperty().bind(widthProperty());
        view.prefHeightProperty().bind(heightProperty());

        goButton.setLayoutX(10);
        goButton.layoutYProperty().bind(heightProperty().subtract(20).subtract(goButton.heightProperty()));
    }
}

The issue I want to fix is that the JavaFX Application has an icon that is shown in the System Tray when running. I am going to use this Application to overlay on top of another program that is running. Thus it would look unprofessional if the icon in the System Tray is showing. I have seen this Stack Overflow post here, but I want to generally avoid adding Swing to my program because it will be messy trying to make both of these GUI API's to match with each other. I heard from an answer in the post that it would be possible in JavaFX 8 and up. Does anyone know a way to hide this JavaFX Application from showing in the System Tray only using JavaFX and not using Swing? Thanks.

Image:

Pulse
  • 59
  • 1
  • 4
  • Why would you ever extend the Application class unless you want to use the JavaFX GUI? Application is one of the core JavaFX classes? And what do you mean by overlying on top of another program that is running? Can you explain more, please? – NomadMaker Sep 02 '20 at 22:58
  • [How can I remove my javafx program from the taskbar](https://stackoverflow.com/questions/46712293/how-can-i-remove-my-javafx-program-from-the-taskbar)? [JavaFX: can you create a stage that doesn't show on the task bar and is undecorated?](https://stackoverflow.com/questions/24564136/javafx-can-you-create-a-stage-that-doesnt-show-on-the-task-bar-and-is-undecora/54253303)? – MadProgrammer Sep 03 '20 at 00:22
  • 1
    Hey @AndrewThompson I am making something called a Minecraft mod, where it uses events inside to open the application. Instead of directly editing the GUI files inside which is much harder, I am putting another application over the one temporary to show some sort of "cut scene" only for a couple seconds, or whatever the user decides the length of the video should be. I'm not trying to neglect the user experience. – Pulse Sep 03 '20 at 01:47
  • 1
    The overlayed screen will close after the video has stopped playing, or the user clicked some sort of "skip" button. You can look at the JavaFX code more clearly here: https://github.com/king-mammoth/King-Mammoth-Cut-Scenes/blob/1.12.X/src/main/java/org/kingmammoth/kmcutscenes/player/YoutubeVideoPlayer.java . I'm not sure if you know the API or not, but I think the JavaFX class is enough to understand. I'm super sorry for the confusion. – Pulse Sep 03 '20 at 01:48
  • The system tray is the small notification area in the lower right corner of the screen. By “system tray” do you mean the entire **task bar** that shows all open windows with their associated icons? – VGR Sep 03 '20 at 11:48
  • @VGR Of course not. That is almost impossible. I just want to hide the window icon shown in the system tray that the JavaFX itself is showing. – Pulse Sep 03 '20 at 23:46
  • I don’t recall seeing a system tray icon when running a JavaFX application. On which version of Windows does this occur? Can you provide a partial screen shot? – VGR Sep 04 '20 at 00:33
  • @VGR https://imgur.com/25wVMan – Pulse Sep 04 '20 at 00:39
  • I can't edit my comment for some reason. Here is the new link to the class (as the old one is invalid now): https://github.com/king-mammoth/King-Mammoth-Cut-Scenes/blob/1.12.X/src/main/java/org/kingmammoth/kingmammothcutscenes/player/YoutubeVideoPlayer.java – Pulse Sep 04 '20 at 20:18

0 Answers0