JMU
An Introduction to Graphical User Interface (GUI) Technology
With Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


The Building Blocks
Some Top-Level Containers (i.e., Realizations of JRootPaneContainer javax.swing.JRootPaneContainer )
Creating a JFrame
javaexamples/gui/JFrameDriver.java
        import java.awt.*;
import javax.swing.*;


/**
 * An example that uses a JFrame
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison Univeristy
 */
public class JFrameDriver
{

    /**
     * The entry point of the example
     *
     * @param args   The command line arguments
     */
    public static void main(String[] args)
    {
        JFrame   f;


        f = new JFrame();
        f.setSize(400,400);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        
        f.setVisible(true);
    }
}
        
Working with Top-Level Containers
Some GUI Components
GUI Layout
Absolute Layout

The "Graph Paper" Approach

images/layout_absolute1.gif
Absolute Layout in Java

The null LayoutManager java.awt.LayoutManager

javaexamples/layout/NullLayoutFrame.java