by Dinesh Thakur Category: Swing

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();
          }        
  }

JFrame ContentPane Layout



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles