|
Hour 24: Making Your Knowledge Add Up
SOURCE CODE FOR THE MINICALC GRAPHICAL USER INTERFACE
- The first step in the development of a project like this
should be to design the graphical user interface. The interface
for the author's MiniCalc project can be found in MiniCalcGUI.java,
MiniCalcGUI.class,
CalcAppletGUI.java,
CalcAppletGUI.class,
and CalcAppletGUI.html.
- One of the requirements of the project was that the equals key
should be disabled when the program starts. This is handled by
calling the
setEnabled(false) method on that
component.
- The interface is created by using two different groups of
components arranged using the
GridLayout layout
manager. The first is created with a call to the
GridLayout(6, 1, 5, 5) constructor method. This
creates a layout of six rows and only one column. The last two
arguments are used to provide some horizontal and vertical space
between each component in the grid. The graphic below shows where
these six rows are located on the interface:
- On each of these rows, another grid layout is used to arrange
the components on that row. This layout manager is created with a
call to the
GridLayout(1, 4, 5, 5) constructor, which
has one row, four columns, and a horizontal and vertical gap of 5
pixels each. The graphic below shows one of these rows, with black
lines around each of the cells in the grid:
- In a container organized by the
GridLayout
manager, the component you put into a cell will expand to fill all
the space that's available to it.
- If you have questions about developing a calculator interface,
contact the author.
READER QUESTIONS
|