How to create a JavaFX Window without the three standard buttons (Minimize, Maximize and Close)?

0
It's basically what this in question, I wanted a screen without those 3 buttons, let's say that without that standard border that comes in basically all windows that opens on windows, and that comes with those 3 buttons, and that started on full screen. I looked at the net and did not find anything similar. Ideas?

    
asked by anonymous 28.09.2017 / 22:04

1 answer

3

You can set the style by using the initStyle() method that receives a StageStyle of your Stage .

Eg:

public class HelloWorld extends Application {

    @Override
    public void start(Stage stage) {
        Text text = new Text(10, 40, "Hello World!");
        text.setFont(new Font(40));
        Scene scene = new Scene(new Group(text));

        stage.initStyle(StageStyle.UNDECORATED)

        stage.setTitle("Welcome to JavaFX!"); 
        stage.setScene(scene); 
        stage.sizeToScene(); 
        stage.show(); 
    }

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

Possible values are:

DECORATED

  

You define the normal Stage style with a solid white background and platform decorations.

  

Define a stage style with a solid white background

TRANSPARENT

  

You define the Stage style with a transparent background and no decorations.

  

Define a stage style with a transparent background and decorations.

UNDECORATED

  

You define the Stage style with a solid white background and no decorations.

  

Set a stage style with a white background and no decorations

UNIFIED

  

Define the Stage style with platform decorations and eliminate the border between client area and decorations.

 
  

Defines a stage style with decorations and eliminates the border between the client area and the decorations

UTILITY

  

You define the Stage style with a solid white background and minimal platform decorations used for a utility window.

  

Defines a stage style with a solid white background and minimal decorations used by a utility screen.

To leave in full screen, you can call the setFullScreen (boolean value) , true to start in fullscreen, false otherwise

    
28.09.2017 / 22:52