//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** @author Casey Bowman * @version 1.1 * @date Sat Feb 28 11:27:41 EST 2015 * @see License (MIT license style) */ import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.FlowLayout; import java.awt.Color; //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** Hello World class with a GUI using javax Swing. * Extends JFrame Class and uses JLabel and FlowLayout * @see http://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html * @see http://docs.oracle.com/javase/7/docs/api/javax/swing/JLabel.html * @see http://docs.oracle.com/javase/7/docs/api/java/awt/FlowLayout.html */ public class HelloWorldGUI extends JFrame { //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** Constructor for HelloWorldGUI class * adds the text and sets up the JFrame */ public HelloWorldGUI (String t) { addText (t); pack (); setSize (200,50); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); setLayout (new FlowLayout ()); setVisible (true); } // HelloWorldGUI constructor //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** addText creates a JLabel with String t as text and adds it * to the JFrame * @param t the text for the JLabel */ public void addText (String t) { JLabel label = new JLabel (t); getContentPane ().add (label); } // addText //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** main method * Creates a new instance of the HelloWorldGUI class with * the text set to "Hello World!". */ public static void main (String[] args) { HelloWorldGUI hwg = new HelloWorldGUI ("Hello World!"); } // main } // HelloWorldGUI