In a Java Swing, A JFrame is the class that represents the window in which graphics applications running on Java. JFrame Class is the top-level container that contains content pane all visible components contain in the content pane. The usual procedure to be used to create a new class that inherits from JFrame. Normally JFrame’s are used as primary containers, that is, not contained in other containers.
A frame is often put a main panel from which the other elements are organized. To place this main panel method is used.
public void setContentPane(Cantainer contentPane)
import java.awt.*;
import javax.swing.*;
public class JFrameContentPane extends JFrame
{
private final int SIZE = 200;
private Container con = getContentPane();
private JButton BtnClckIt = new JButton("Click it");
public JFrameContentPane()
{
super("JFrame ContentPane Layout in Java Swing Example");
setSize(500,500);
setVisible(true);
con.setLayout(new FlowLayout());
con.add(BtnClckIt);
}
public static void main(String[] args)
{
JFrameContentPane JFrameCP = new JFrameContentPane();
}
}