Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Hiding Frame in Java 
 

This section illustrates you how to hide the Java Awt frame. Here, you have seen in the given following example that provides you the complete code of the program.

 

Hiding Frame in Java

                         

Introduction

This section illustrates you how to hide the Java Awt frame. Here, you have seen in the given following example that provides you the complete code of the program.

Description of  program:

In this program, program you will see that only one method of the frame is important for the purpose. The following program show a frame titled with "Frame Hiding". When you click on the close button of the frame, the frame will not be closed but it will hide certain with holding all frame data as it is.

In this program, program we are handling the event generated by the frame when you click on the close button of the frame. By using the getSource() method of the WindowEvent class we are creating the Frame object and frame hides when you call the setVisible() method by passing a boolean valued argument.

Method's Description:

getSource(): This is the method of EventObject class. Hence, here this method is used for the WindowEvent class so, it can return the Form's object that is done invisible by using the setVisible() method. The getSource() method returns the source of the generated event.

setVisible(false): This is the method of Form class i.e. used for setting the form whether visible or not. This method takes a boolean valued argument which decides the form for visible or not. If you pass the boolean value false then the form will be invisible otherwise if you argument is true then the form object will be visible. By default Java Awt Form is in the invisible state. For showing the form you have to set the form visible by using the setVisible(true) method.

Here is the code of program:

import java.awt.*;
import java.awt.event.*;

public class  FrameHide{
  public static void main(String[] args){
    Frame fa= new Frame("Frame Hiding");
    Panel p =new Panel();
    Label l1=new Label("Welcome roseindia");
    p.add(l1);
    fa.add(p);
    fa.setSize(300,200);
    fa.setVisible(true);
    fa.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
      Frame frame = (Frame)e.getSource();
      frame.setVisible(false);
       }
    });
   }  
}

Output of this Program:

 

Download this example.

                         

» View all related tutorials
Related Tags: c class make method sed boolean value ole set oo frame if boo to ram bool argument e il not

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.