JFrame f = new JFrame("Title of the Window");
|
Note:
|
|
import java.awt.*;
import javax.swing.*;
public class Frame1
{
public static void main(String[] args)
{
JFrame f = new JFrame("My First GUI"); // Create Frame
f.setSize(400,300); // Set size of frame
f.setVisible(true); // Show the window
}
}
|
|
JLabel L = new JLabel("Text");
|
JLabel L = new JLabel("Text");
JFrame f = new JFrame("Window Title");
f.getContentPane().add( L ); // "Stick" object L onto the frame f
|
Example:
import java.awt.*;
import javax.swing.*;
public class Frame2
{
public static void main(String[] args)
{
JFrame f = new JFrame("My First GUI");
f.setSize(400,300);
JLabel L = new JLabel("Hello World !");
f.getContentPane().add( L );
f.setVisible(true);
}
}
|