Frame is the most common container used to create top-level window having title, border and window-management buttons. It can also be used to create secondary windows for an application. A frame is an object of JFrame class.
The constructors defined by this class JFrame class are as follows.
JFrame ()
JFrame(String title)
where,
title specifies the title for the frame
Example :
import java.awt.*;
import javax.swing.*;
public class JFrameColor extends JFrame
{
private final int SIZE = 100;
private Container cntnr = getContentPane();
private JButton BtnClckHere = new JButton("Click Here");
public JFrameColor()
{
super("JFrame Color in Java Swing Example");
setSize(200,150);
setVisible(true);
cntnr.setLayout(new FlowLayout());
cntnr.add(BtnClckHere);
cntnr.setBackground(Color.YELLOW);
BtnClckHere.setBackground(Color.blue);
BtnClckHere.setForeground(Color.cyan);
}
public static void main(String[] args)
{
JFrameColor frame = new JFrameColor();
}
}