/* DaGui0.java CIS 160 2014-10-23 David Klick Very basic GUI demonstration. */ import java.awt.BorderLayout; import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public class DaGui0 extends JFrame { public static void main(String[] args) { // Create a new object out of ourself when program starts // This object will be the JFrame that is displayed on the screen. new DaGui0(); } // default constructor public DaGui0() { // Create a thread to run in the EDT (Event Dispatch Thread) // as soon as it gets a chance. This is the GUI thread. SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } // This is the method that actually assembles the GUI. public void createAndShowGUI() { // Get container to hold GUI components. Container c = getContentPane(); // Set container layout manager. c.setLayout(new BorderLayout()); // Create widgets. JLabel label = new JLabel("Hi"); JButton btn = new JButton("Klick me"); // Add widgets to container. c.add(btn, BorderLayout.CENTER); c.add(label, BorderLayout.NORTH); // Enable close icon and display GUI. setSize(500, 400); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); } }