The sample programs we have written so far used standard classes such as
JOptionPane, PrintStream (System.out is an instance of PrintStream), and others
for handling user interface. These standard classes are convenient and adequate for
a basic program that does not require any elaborate user interface. For example,
when we need to input a single integer value, calling the showInputDialog method
of JOptionPane once to read that input is appropriate and effective. However,
when we need to input, say, 10 values for a Student object (e.g., name, age, address,
phone number, GPA), then calling the showInputDialog method 10 times is
not adequate. It is very cumbersome to go through 10 input dialogs and enter a
value one at a time. Also, there is no simple and elegant way to allow the user to
reenter any one of the values after all 10 input values are entered. So, instead of
using 10 input dialogs, it is a much better user interface to employ a single customized
window that allows the user to enter all 10 values. We will learn how to
build such a customized user interface in this chapter. As a part of building of a
customized user interface, we will also learn how to detect mouse movements and
clicking of mouse buttons.
To learn more about the book this website supports, please visit its Information Center.