/* GUI05.java CIS 160 David Klick 2011-09-24 Creating and adding components - no layout manager Notice: only 1 component will show up */ import java.awt.Container; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public class GUI05 extends JFrame { public GUI05() { SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } private void createAndShowGUI() { // set title, size, and close operation setTitle("No Layout Manager"); setSize(300, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // create components JLabel lblLength = new JLabel("Length:"); JLabel lblWidth = new JLabel("Width:"); // add components to this frame's content pane Container c = getContentPane(); c.add(lblLength); c.add(lblWidth); setVisible(true); } public static void main(String[] args) { GUI05 app = new GUI05(); } }