Hello World Swing : Basics « Swing JFC « Java






Hello World Swing

Hello World Swing

import javax.swing.JFrame;
import javax.swing.JLabel;

public class HelloWorldSwing {
  public static void main(String[] args) {
    JFrame frame = new JFrame("HelloWorldSwing");
    final JLabel label = new JLabel("Hello World");
    frame.getContentPane().add(label);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
}


           
       








Related examples in the same category

1.Separating GUI logic and business objectsSeparating GUI logic and business objects
2.Creates two JPanels (opaque), one containing another opaque JPanel, and the other containing a non-opaque JPanelCreates two JPanels (opaque), one containing another opaque JPanel, and
the other containing a non-opaque JPanel
3.The revalidate method to dynamically update theThe revalidate method to dynamically update the
4.Swing ApplicationSwing Application
5.This example demonstrates the use of JButton, JTextField and JLabelThis example demonstrates the use of JButton, JTextField and JLabel
6.CelsiusConverter: the use of JButton, JTextField and JLabelCelsiusConverter: the use of JButton, JTextField and JLabel
7.GUI invoked from the event-dispatching threadGUI invoked from the event-dispatching thread
8.Standalone GUI program that shows paint, repaint, and updateStandalone GUI program that shows paint, repaint, and update
9.LunarPhases: the use of JButton, JTextField and JLabel