This is a simple program to create a window, in java we can design GUI’s( Graphical User Interfaces ) using the concept of swings.
In this example i have used the class called JFrame which is predefined in the package javax.swing. to use this class we have to write import statement.
Mywindow is a user defined class which extends( inheritance ) JFrame
class, by extending the existing JFrame class we can develop our own application that’s what the application of inheritance is.
1st line i.e Class Mywindow extends JFrame is extending the JFrame class.
2nd line i.e Mywindow()
it is constructor here it is used to define the characteristics of the window to be displayed like it’s title,size ( width and height )
the method setVisible( true ) makes the window to be visible,setDefaultCloseoperation( JFrame.EXIT_ON_CLOSE ) this line is written close the window soon after clicking the cancel button of the window by default it wont get closed.
inside the main the object has been created by the statement Mywindow m1=new Mywindow() which intern invokes constructor and constructor makes the window to be visible.