0

i came through How can I remove my javafx program from the taskbar post but the problem in this post is that method did't show any window even i tried that sample in the post but still didn't work if i fully comment the initowner a undecroted window shows but also in the taskbar,

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * Main class of the application.
 */
public class QuickNote extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.initStyle(StageStyle.UTILITY);
        primaryStage.setOpacity(0);
        primaryStage.setHeight(0);
        primaryStage.setWidth(0);
        primaryStage.show();
        Stage mainStage = new Stage();
        mainStage.initOwner(primaryStage);           // this line
        mainStage.initStyle(StageStyle.UNDECORATED);
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });
        StackPane root = new StackPane();
        root.getChildren().add(btn);
        mainStage.setScene(new Scene(root, 300, 250));
        mainStage.show();
    }
}

So, How can i make a stage to not apper in taskbar and should be undecorated ?

srilakshmikanthanp
  • 2,231
  • 1
  • 8
  • 25

0 Answers0