JFrame in Java:
The JFrame in java is a class which is used to create a user-defined window. The JFrame class defines the following constructors:
JFrame()
It is used to create empty JFrame.JFrame(String str)
It is used to create a JFrame with the specified string.Methods for JFrame in Java:
Container getContentPane()
The getContentPane() method is used to return the content pane object for this JFrame.void add(component c)
This method is used to add the given components to the content pane of this frame.Sample program for JFrame in java:
import java.awt.*;import java.awt.event.*;
import javax.swing.*;
public class JFramedemo
{
public static void main(String arg[])
{
JFrame jf= new JFrame("online help");
Container c=jf.getContentPane();
c.setLayout(new BorderLayout());
c.add(new JButton("yes");
jf.setBounds(0,0,300,200);
jf.setVisible(true);
}
}
No comments:
Post a Comment