Java examples for Swing:JFrame
JFrame is a top-level container.
The following code creates a JFrame object with its title set to "Simplest Swing":
// Create a JFrame object JFrame frame = new JFrame("Simplest Swing");
To make it visible.
// Make the JFrame visible on the screen
frame.setVisible(true);
The following is the complete code to create and display a JFrame.
import javax.swing.JFrame; public class Main { public static void main(String[] args) { // Create a frame JFrame frame = new JFrame("Simplest Swing"); // Display the frame frame.setVisible(true);//from w w w. java 2 s.c o m } }