Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove JavaFX stage buttons (minimize, maximize, close)

Tags:

javafx-2

How to remove JavaFX stage buttons (minimize, maximize, close)? Can't find any according Stage methods, so should I use style for the stage? It's necessary for implementing Dialog windows like Error, Warning, Info.

like image 492
Anton Avatar asked Dec 01 '11 12:12

Anton


People also ask

How do you remove minimize maximize close button from JFrame?

Try this code: JFrame frame = new JFrame("Example"); frame. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); frame.

How do I hide a button in Scene Builder?

Set the visible property to false. The simplest way to hide a button from the display is to invoke setVisible() on the button object. Passing the boolean value false will have the effect of making the button completely invisible.


2 Answers

If you want to disable only the maximize button then use :

stage.resizableProperty().setValue(Boolean.FALSE);

or if u want to disable maximize and minimize except close use

stage.initStyle(StageStyle.UTILITY);

or if you want to remove all three then use

stage.initStyle(StageStyle.UNDECORATED);
like image 117
Shardendu Avatar answered Oct 16 '22 06:10

Shardendu


You just have to set a stage's style. Try this example:

package undecorated;

import javafx.application.Application;
import javafx.stage.StageStyle;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class UndecoratedApp 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();
    }
}

When learning JavaFX 2.0 these examples are very helpful.

like image 25
pmoule Avatar answered Oct 16 '22 07:10

pmoule