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.
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:
Output of this Program:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.