- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we disable the maximize button of a JFrame in Java?
A JFrame is a class from javax. swing package and it can extend java.awt.frame class. It is a top-level window with a border and a title bar. A JFrame class has many methods that can be used to customize it.
After setting the size of a JFrame we can still change the size by putting the cursor at the corners and dragging it or if we press resize option next to close at the top right corner, it will maximize to the size of a full screen. This happens because resize is set to true by default for JFrame class. We can make it as false as setResizable(false), now it can appear according to the dimensions we have given in the code and it cannot be resizable.
Example
import java.awt.*; import javax.swing.*; public class JFrameDemo extends JFrame { String title; public JFrameDemo(String title) { super(title); add(new JLabel("JFrame with maximize button disabled"), BorderLayout.CENTER); setSize(350, 275); setLocationRelativeTo(null); setResizable(false); // maximize button disable setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void main(String args[]) { new JFrameDemo("JFrame Demo"); } }
Output
- Related Articles
- How can we minimize/maximize a JFrame programmatically in Java?
- How to disable close button on a JFrame in Java?
- Can we disable JComboBox arrow button in Java?
- How to maximize JFrame in Java Swing
- How to close JFrame on the click of a Button in Java
- How can we disable the leaf of JTree in Java?
- How to set default button for JFrame in Java?
- How can we disable the cell editing inside a JTable in Java?
- How to set the location of a button anywhere in JFrame?
- How can we disable cut, copy and paste functionality of a JTextArea in Java?
- How can we set Mnemonic Key Radio Button in Java?
- Disable a Bootstrap Button
- How to Disable / Enable a Button in TKinter?
- Disable a button with Bootstrap
- How can we ENABLE AND DISABLE a particular MySQL event?

Advertisements