Remove Minimize and Maximize Button of Frame in Java

In this section we are going to learn the coding methods to remove the minimize and maximize button from the title bar of a frame.

Remove Minimize and Maximize Button of Frame in Java

In this section we are going to learn the coding methods to remove the minimize and maximize button from the title bar of a frame.

Remove Minimize and Maximize Button of Frame in Java

Remove Minimize and Maximize Button of Frame in Java

     

In this section we are going to learn the coding methods to remove the minimize and maximize button from the title bar of a frame. We know that the title bar contains icon, minimize, maximize and close buttons. The following program provides the facility for doing it. That means, the frame or window displays on the screen without minimize and maximize button but it has only the icon and close button on the title bar that helps us at the time of closing the frame or window. See more information below.

Description of program:

This program displays a frame under the dialog box that hasn't the minimize and maximize button. It contains only a close button that performs only closing operation that means our window closes when you click on it. So follow the program for better understanding and you will find that the title bar has only close botton.  

Here is the code of program:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class RemoveMaxAndMinButton extends JDialog{
  public RemoveMaxAndMinButton(JFrame frame, String str){
  super(frame,str);
  addWindowListener(new WindowAdapter(){
  public void windowClosing(WindowEvent evt){
  System.exit(0);
  }
  });
  }
  public static void main(String[] args){
  try{
  RemoveMaxAndMinButton frame = new RemoveMaxAndMinButton(new JFrame(),
    
"Remove the Minimize and Maximize button from the Title Bar");
  JPanel panel = new JPanel();
  panel.setSize(200,200);
  JLabel lbl = new JLabel("RoseIndia.Net");
  panel.add(lbl);
  frame.add(panel);
  frame.setSize(400400);
  frame.setVisible(true);
  }
  catch(IllegalArgumentException e){
  System.exit(0);
  }
  
}

Download this example.

Output of program: