A graphical application shows information inside a frame: a window with a title bar.

To show a frame carry out the following steps:

An empty frame is not that interesting.

You will want to add some user interface elements: buttons, text labels, etc.

If you have more than one component you can put them in a panel, then add the panel to the frame.

You can achive the same effect (that is, of customizing the frame you're building) through inheritance.

Notice that when you add more than one component to a frame they're placed on top of each other.

Adding one component (e.g., the panel) is immune to that problem; also, panels have a default flow layout.

If you want to place components in specific places you need to work with the layout manager, perhaps disabling it, etc.

In an event-driven user interface the program receives an event whenever the user manipulates an input component.

One could use inner classes for listeners, we'll postpone recommending that until the end of the chapter.

Most graphical user interfaces collect text input through text components.

You notice that we go against Programming Tip 10.1 because we have web programming in mind.

If you want to generate a drawing you can use a JComponent instead of a panel, and draw on it.

(The program shown above is related to P4.26 in your text, only it throws darts instead of needles).

We have reviewed action listeners above and you have seen mouse listeners as early as lab seven:

The lab was starting from Point.java and Circle.java developed in lecture along with One.java and Two.java.

The goal of the lab was to fix that one line of code in Two.java and add a new type of movable shape to the program (e.g., Rectangles).

Besides you have seen applets: simple scribble and more sophisticated scribble that were using the mouse types of events.

The third type of listener we need to mention before we end is represented by key listeners.