---
title: How to maximize JavaFX undecorated window | 100% Best for beginners
url: https://kensoftph.com/how-to-maximize-javafx-undecorated-window/
date: 2021-06-26T02:07:00+00:00
modified: 2022-09-24T07:23:12+00:00
lang: en_US
---

# How to maximize JavaFX undecorated window | 100% Best for beginners

## JavaFX Tutorial

This tutorial will teach you how to maximize JavaFX undecorated window. If you are developing a JavaFX application with an undecorated window design. So you'll need this tutorial. So, let's get this party started.

## How to maximize JavaFX undecorated window

To maximize your JavaFX undecorated window application. You need to use the **setMaximized(boolean)** method to [maximize your window in JavaFX](https://stackoverflow.com/questions/6864540/how-to-set-a-javafx-stage-frame-to-maximized). A boolean parameter is passed to the **setMaximized(boolean)** method. You have the option of using **true** or **false**. When you set the parameter to true, your JavaFX undecorated window will be maximized.

## Example

```
stage.setMaximized(true);
```

Once your JavaFX undecorated window has been maximized, you can restore it to its original size. To return it to its original size, you must redefine the **setMaximized()** method and set the parameter to false.

To achieve the desired result. You must use the if statement. Using the **if statement**, create a condition. If the window is maximized, you must restore it to its original size. When the window is in its original state. Then you could maximize it again.

## Example

In this example, I'll show the entire code to maximize JavaFX undecorated window and restore the window to its original size. I'm going to use this code in the controller, and I'm going to use the mouse event.

```
@FXML
private void Maximized_clicked(MouseEvent event) {
   Stage stage = (Stage) maximized_button.getScene().getWindow();
      if(stage.isMaximized()){
         stage.setMaximized(false);
      }else{
          stage.setMaximized(true);
      }
}
```

[![Maximize JavaFX Undecorated window](https://kensoftph.com/wp-content/uploads/2021/06/maximize-javafx.png)](https://kensoftph.com/wp-content/uploads/2021/06/maximize-javafx.png)

## YouTube Video

https://youtu.be/4EGUXYb2TBU
