I usally use Netbeans IDE for my Java application development. When I design my application GUI, I like to have my main GUI to be automatically maximized to the full Computer screen. I mean that the width and height of the main GUI windows should be equal to the computer screen width and height respectively after starting up the application.
We can achieve this in Netbeans using the following steps.
1) After adding a new JFrame Form .. with a name such as “MainUI.java”.
2) Click on MainUI.java in the Project window
3) In the Inspector windows under the Project window, click on the [JFrame]. Then, we will see that the Properties window on the right hand side is changed to [JFrame] Properties.
4) In the [JFrame] Properties windows, click on … next to the “preferredSize” property. A new [JFrame] preferredSize window will be poped up.
5) In the “preferredSize” property window, click on “Advanced…”.
6) Another “preferredSize — Advanced Initialization Code” windows is popped up. Check the box in front of “Generate Post-initialization Code”, and enter the code below.
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dimension = tk.getScreenSize();
int screenWidth = dimension.width;
int screenHeight = dimension.height;
7) Click OK and Close. Now, try to right click on the “MainUI.java” and then click “Run File”. The MainUI window should be maximized to the full screen. If there is a problem about Toolkit class not found exception, just right click anywhere in the source code and then click “Fix import”.