Java Reference
In-Depth Information
Compiling the Rooms Class Source Code
The Rooms class is complete. The next step is to compile the Rooms class
source code to create a reusable class object, as shown in the following steps.
To Compile the Rooms Class Source Code
1. With your Data Disk in drive A, click Compile Java on the Tools menu.
2. If the Rooms class contains errors, fix them in the coding window and
then recompile the program.
TextPad compiles the source code for the Rooms class.
OTHER WAYS
1. Press CTRL + 1
2. At command
prompt, type javac
Rooms.java
The Rooms class now can be used or called from any Java application that
needs this kind of class. If you want to document the source code, you can
print a copy of the code for later reference by clicking the Print button on the
Standard toolbar in the TextPad window.
Creating Windowed Applications
Recall that the Abstract Window Toolkit is the basic set of Java classes used to
build graphical user interfaces for Java applets and applications. Using the AWT,
programmers have access to tools for creating common graphical objects such as
windows, dialog boxes, buttons, areas in which to manipulate text, and much
more. The AWT also specifies an event-handling model that enables a Java
program to respond to the keystrokes and mouse-clicks entered by a user.
The AWT is abstract or conceptual, in that it provides only the essential
components and functionality that are common to all major operating systems
that support windowed applications. For example, Microsoft Windows, Apple
Mac OSX, and Unix all allow a user to click a button to execute an action. The
physical appearance of the button, precise behavior, and the application program
interface (API), however, differ significantly for each of the three environments.
(Recall that an application program interface is a standard set of interfaces and
classes functionally grouped into packages; these APIs are present in any Java
implementation.) Java abstracts the essential behavior of a button and provides
an API that is presented to the developer in the AWT. When an instance of the
Java Button class is compiled, the actual button presented to the user is obtained
from the native, or operating system, environment of the user's computer. The
same is true for many of the other AWT components, including the window
itself.
Recall that Swing components use lightweight Java implementations of the
standard GUI controls. While Swing components increasingly are used to create
windowed applications, the Swing classes typically are not used on Java certifica-
tion exams because they do not create native controls, as do the AWT controls.
Additionally, some Swing components do not work with all browsers.
Search WWH ::




Custom Search