Java Reference
In-Depth Information
topic. Packages correspond to directories/folders. The directory structure looks
like this:
Unix/Linux: its/[subPackageName]/[sourceFileName].java
MS-Windows: its \ [subPackageName] \ [sourceFileName].java
where you have to insert the appropriate names for [subPackageName] and
[sourceFileName] .
To compile and then run a program go to the super-directory of its and issue
the following commands:
javac its \ [subPackageName] \ [sourceFileName].java java
its.[subPackageName].[sourceFileName]
Note that dots are used instead of the slashes in the java command. The file path
separators are different on different operating systems. Look at Section B.5 in
Appendix B for solutions to some common problems.
The its -package can be downloaded as a ZIP-file from the topic's home page
( http://www.imm.dtu.dk/swingbook/ ). It is in Windows file format so if you are
on Linux or Unix you might see a CR or an <M> at the end of every line. Use
dos2unix to get rid of it.
The correct directory structure is reconstructed when the ZIP-file is recon-
structed. To test it, go to the super-directory of its and type commands:
javac its \ Test \ Test.java
java its.Test.Test
You should get the picture in Figure 1.1. If you get error messages, see Section B.5.
The example programs follow the paradigm of object-orientation in that we de-
fine a class for every customized component. Most applications are started from
a separate start class (driver). The names of the start classes end with Driver .
All the example programs are very simple because we want to concentrate on the
graphical concepts. This means that we also omit tests that check for safety and
plausibility. For example, if the size of a graphical component is set to certain
values we do not check whether the values are positive, neither do we check
Figure 1.1 Result of the test program
Search WWH ::




Custom Search