Java Swing GUI

How to Fix the Size of JFrame in Java

In this tutorial, we are going to see how to fix the size of JFrame in Java. You can change the size of the JFrame by simply placing the cursor in the corners and dragging it. Or if you press the resize option next to close(X) in the upper right corner, it will be enlarged to full-screen size. This happens because the resize is set to “true” by default. You can simply set it to “false”, using JFrame.setResizable(false) method.

Java Program to Fix the Size of JFrame:
import javax.swing.JFrame;

public class Main 
  public static void main(String[] args)
	JFrame frame = new JFrame();
	frame.setSize(300, 300);  
	//Fix the Size of the JFrame	


mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *