Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Example Java Swing Iconifying and Maximizing a frame in Java

Related Tutorials


 
 

Share on Google+Share on Google+

Iconifying and Maximizing a frame in Java

Advertisement
In this section, you will learn about the Iconifying and maximizing a frame in java.

Iconifying and Maximizing a frame in Java

     

In this section, you will learn about the Iconifying and maximizing a frame in java. Iconifying means to show a frame in minimized form. This program displays a frame in both forms. By default the frame will be in the minimized form. Following is the image of the frame which has to be minimized or maximized: 

This is normal window which has to be maximized

Code Description:

frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG):
The setWindowDecorationStyle() is the method of the JRootPane class which sets the window decoration type using the constant property PLAIN_DIALOG of the JRootPane class.

setExtendedState():
It sets the state of window to minimize and maximize. It uses the constant field of the JFrame class.

MAXIMIZED_BOTH
This state is used to maximize the frame horizontal and vertical.

ICONIFIED
This state checks whether the frame is minimized or not.

Here is the code of program:

import javax.swing.*;

public class IconifyAndMaximizeFrm{
  public static void main(String[] args){
  JFrame frame = new JFrame("Iconifying and Maximizing a Frame");
  frame.setUndecorated(false);
  frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
  frame.setExtendedState(JFrame.MAXIMIZED_BOTH);  //Maximizing the frame
  frame.setExtendedState(JFrame.ICONIFIED | frame.getExtendedState());
  
//Minimizing or Iconifing the frame
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
  }
}

Download this example.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 14, 2007

Related Tutorials

Discuss: Iconifying and Maximizing a frame in Java   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
dinesh
April 13, 2012
maximized form

thanx so much for the help....
suganya
April 15, 2012
form close

i hv used JprogressBar coding in one form ..after thread process over i invoked one new form by calling its constructor..bt the pbm is i need to close my form containin the component JprogressBar.......... How to close the current form when i open new form in java(both r jFrame)?...HomePageAccess().setVisible(false) is not wrking.....can someone help me?........ thnx in advance..
DMCA.com