Basic GUIs

Graphical User Interfaces

A Graphical User Interface allows a user to enter data using a screen of graphical components, rather than a series of prompts, like a character-based interface.

The user can fill out the data in the order they wish, and the GUI reacts in real-time.

For instance, often when a user presses a button, the data is processed.

This type of programming is called Event-Driven.

To create a graphical user interface (GUI, pronounced goo-ee), you will:

Swing

Components

Components are the basic building-blocks for creating a Gui.

Layout Managers

Layout Managers control how Components are laid out on the screen.

RunGUI application

The RunGUI.java doesn't do anything (so no event handling). It runs one of the examples GUIs:

  1. FlowGUI
  2. GridGUI
  3. BorderGUI

Here is the abstract class used by the 3 GUIs:

Here is the BetterGUI that uses multiple layout managers:

Each of the GUIs just demonstrates using the layout manager to add components.

Resources

  • The Swing Tutorial (Oracle Tutorial)
  • Lesson: Java Applets (Oracle Tutorial) - Optional, Applets have been deprecated.