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
.
Try this code: JFrame frame = new JFrame("Example"); frame. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); frame.
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.
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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With