header

Graphical User Interfaces

A graphical user interface allows the user to interact with graphic elements such as buttons and text fields. Creating an application with a graphical user interface involves three steps: design the interface, write the code to create the interface, and then write the code to implement the user interaction with the interface. These steps are performed in this order and, ideally, you don't work on any step until the previous steps have been completed. In essence, if you must go back to an earlier step, then you didn't really complete that step in the first place.

Design the Interface

When designing the interface, you must determine what components will be on the interface and how they will be arranged. The declarations of these components are placed at the top of the class code as class variables so they can be accessed anywhere within the class.

Create the Interface

You create the interface by constructing and initializing all of the components and then adding the components to the application window. All of this is done within a method whose sole purpose is to create and show the graphical user interface.

Implement the User Interaction

Once the interface looks the way you want it to look, you write the code that determines what happens when a user interacts with its components. This code is implemented in the actionPerformed method of the application.