Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX: Undecorated Window

I am attempting to make a Windows PC Toast notification. Right now I am using a mixture of Swing and JavaFX because I did not find a way to make an undecorated window with FX. I would much prefer to only use JavaFX.

So, how can I make an undecorated window?

Edit: I have discovered that you can create a stage directly with new Stage(StageStyle.UNDECORATED).

Now all I need to know is how to initialize the toolkit so I can call my start(Stage stage) method in MyApplication. (which extends Application)

I usually call Application.launch(MyApplication.class, null), however that shields me from the creation of the Stage and initialization of the Toolkit.

So how can I do these things to allow me to use start(new Stage(StageStyle.UNDECORATED)) directly?

like image 985
Dorothy Avatar asked Nov 14 '11 22:11

Dorothy


People also ask

How do I create a new JavaFX window?

javafx Windows Creating a new Window // create sample content Rectangle rect = new Rectangle(100, 100, 200, 300); Pane root = new Pane(rect); root. setPrefSize(500, 500); Parent content = root; // create scene containing the content Scene scene = new Scene(content); Stage window = new Stage(); window.

What is window in JavaFX?

A top level window within which a scene is hosted, and with which the user interacts. A Window might be a Stage , PopupWindow , or other such top level. A Window is used also for browser plug-in based deployments.


1 Answers

I don't get your motivation for preliminary calling the start()-method setting a stage as undecorated, but the following piece of code should do what you want to achieve.

package decorationtest;  import javafx.application.Application; import javafx.stage.StageStyle; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage;  public class DecorationTest extends Application {      public static void main(String[] args) {         Application.launch(args);     }      @Override     public void start(Stage primaryStage) {         primaryStage.initStyle(StageStyle.UNDECORATED);          Group root = new Group();         Scene scene = new Scene(root, 100, 100);          primaryStage.setScene(scene);         primaryStage.show();     } } 
like image 86
pmoule Avatar answered Sep 22 '22 04:09

pmoule