A JFrame object is a window with a title, a border, a window menu, resizing buttons, and a close button. A frame can also have a menu bar. A Java application uses a frame to display its graphical user interface.
The JFrame class is included in the statement: import javax.swing.*;
JFrame() JFrame(String title)
The title parameter in the second constructor will appear at the top of the frame window.
pack()
Causes the frame to be optimally sized.
setDefaultCloseOperation(int operation)
Set the operation that should be performed when the user closes the JFrame window. In our programs, we want the application to terminate when the window is closed:
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(boolean b)
Make the frame visible. You should pack the frame before making it visible.