About the CD-ROM

Java > Core SWING advanced programming > Preface > About the CD-ROM

 

The CD-ROM that accompanies this book has the following directory structure:

 EXAMPLES    EXAMPLES.ZIP COREJFC    CH10.PDF SOFTWARE    NETBEANS       NBDX2212.EXE       NBDX2212.SH    SWINGBUILDER       SB2.EXE       SWINGBUILDER-2_0-2_NOARCH.RPM 

The Example Source Code

The source code for all of the examples in this book are provided in a ZIP file in the EXAMPLES directory of the CD-ROM. The same source code is used both for JDK 1.1 and Java 2. Before extracting and installing the examples, you should make sure you have a working JDK and that your environment is set up properly so that you can run the Java compiler and run compiled Java code.

Extracting the Example Source Code

To use the examples, you need to extract them from the ZIP file and compile them. Although you can install them anywhere you like, throughout this book we'll assume that you use a directory called

 c:\AdvancedSwing\Examples 

as the base location for the example source code. If you are working on a UNIX platform, you will probably install the example source code under your home directory and you will have to make the necessary adjustments to the path names that appear in this book. The simplest way to extract the example code is to use a visual tool like winzip or the DOS command line program pkunzip. Alternatively, you can use the JDK jar command; assuming that your CD-ROM appears as drive D, the following commands will install the example source code:

 cd c:\AdvancedSwing\Examples jar xvf D:\Examples\Examples.zip 

The example code is arranged so that the examples for each chapter have their own separate package and this is reflected in the directory structure, which makes it easy to see which source code relates to each chapter of the book. The examples for Chapter 1 reside in the package Advanced-Swing.chapter1. In terms of your machines file system, the source code for these examples will be found in the directory

 C:\AdvancedSwing\Examples\AdvancedSwing\Chapter1 

Much of the example code is reproduced in the book, but this is not always the case. Where there is repetition or there is a relatively large amount of code that is part of the example but that does not help to explain the points being described, only the most interesting portions of the example will be shown. You can always find the complete source code for any example in the appropriate directory, using the name of the main class of the example to find the source file concerned. In all cases in which code has been omitted you will find a note to this effect.

Updates to the examples will be posted from time to time on the author's Web site at http://www.topley.demon.co.uk/corebooks.html.

Compiling the Examples

The examples on the CD-ROM have been tested with both JDK 1.2.2 and Swing 1.1.1 on JDK 1.1.8. Compiled class files are included for the Java 2 platform. If you are intending to use the example code with JDK 1.1 or if you want to try out your own modifications to them, you will need to recompile them.

Before attempting compilation, make sure that your CLASSPATH is properly set. The CLASSPATH will need to include the base directory for the example code as well as the location of the JDK and the Swing packages (at least for JDK 1.1). If you already have a working JDK 1.1 environment, all you need to do is put the directory

 C:\AdvancedSwing\Examples 

in your CLASSPATH. Here is a typical CLASSPATH for JDK 1.1.8 and Swing 1.1.1:

 c:\AdvancedSwing\Examples;c:\jdk1.1.8\lib\classes.zip;c:\    swing-1.1.1\swingall.jar 

Note that it is very important to include the base directory for the examples in the CLASSPATH, not the directories in which the examples themselves reside. Thus, for example, it would be incorrect to include in the CLASSPATH the directory

 c:\AdvancedSwing\Examples\AdvancedSwing\Chapter1 

If you are using Java 2, the JDK software is not accessed via the CLASSPATH variable and you only need to include a reference to the example code in your CLASSPATH. The following DOS command would be sufficient to set up the CLASSPATH for Java 2:

 set CLASSPATH=c:\AdvancedSwing\Examples 

Once you have the correct classpath, you should compile the examples in each directory separately. For example, to compile the examples for the first two chapters, you should do something like this:

 cd c:\AdvancedSwing\Examples\AdvancedSwing\Chapter1 javac *.java cd c:\ AdvancedSwing\Examples\AdvancedSwing\Chapter2 javac *.java 

The class files will be placed in the same directory as the corresponding source. Note that, if you are using JDK 1.1, you should not attempt to compile the examples for Chapters 5 and 8, since these apply to Java 2 only.

Running the Examples

Exact instructions for running each example appear along with the description of the source code throughout the book. A typical command line for executing an example looks like this:

 java AdvancedSwing.Chapter1.TextFieldExample 

The important thing to note is that you must supply the full name of the class, including the package prefix. It would be incorrect to try to short circuit this by using only the terminal part of the name, even if you attempt to adjust the CLASSPATH to compensate. Thus, for example, the following does not work:

 set CLASSPATH=c:\AdvancedSwing\Examples\AdvancedSwing\Chapter1 java TextFieldExample 
The COREJFC Directory

The COREJFC directory contains a complete copy of Chapter 10 of Core Java Foundation Classes in PDF format. In order to make use of this file, you will need to use a program such as Adobe's Acrobat Reader, which can be downloaded from:

http://www.adobe.com/products/acrobat/readstep.html

Chapter 10 of Core Java Foundation Classes contains an in-depth discussion of the Swing JTree component and demonstrates, among other things, how to use JTree to display a hierarchical view of a file system similar to the one used by Windows Explorer. One of the more useful features of Windows Explorer is the ability to copy, move, and link files in the file system by dragging and dropping icons in the Explorer window. Drag-and-drop was not available in JDK 1.1, but it is a part of Java 2. In Chapter 8 of this book, we build on the Core Java Foundation Classes implementation and show you how to add drag-and-drop capability to a tree. If you don't have a copy of Core Java Foundation Classes, you will find the PDF file on the CD-ROM useful since you will need to review the original implementation before studying the extension to it shown in this book.

The SOFTWARE Directory

The SOFTWARE directory contains two substantial pieces of software that you will almost certainly find useful as a Swing developer. You may install and use either or both of these packages on your system without paying a royalty to the company that produces them, but you should read the license terms at the back of this book before doing so. By installing the software on your system, you are deemed to accept the terms of the license. Note that neither Prentice Hall nor the author provides any support for this software. If you have any problems installing this software, please refer to the developers' Web sites as indicated in the following paragraphs.

NetBeans

NetBeans is a complete integrated development environment implemented in Java and uses Swing components for its user interface. The CD-ROM contains two versions of the Developer X2 version 2.1.2 product, one for Windows and the other for UNIX. To install NetBeans, you must already have Java 2 installed on your system. Both copies of the software are located in the SOFTWARE\NETBEANS directory of the CD-ROM.

To install the Windows version, just double-click the file nbdx2212.exe. The installation is performed using a standard InstallShield installer. UNIX users should change directory to SOFTWARE/NETBEANS and use the Bourne Shell to run the installer:

 sh nbdx2212.sh 

NetBeans is a free IDE, so the software on the CD-ROM is a fully working version. If you have any difficulty installing or using NetBeans, you can get help at:

http://www.netbeans.com/support.html

SwingBuilder

SwingBuilder is a utility that allows you to visually create Swing-based user interfaces. Unlike NetBeans, it is not a complete development environment. Instead, it is one component of a suite of IDE tools produced by SwingSoft, a UK-based company who can be contacted via their Web site at http://www.swingsoft.com, where you can also find details of the other IDE component that they provide. SwingBuilder is written entirely in Java and is bundled with the Java Runtime Environment version 1.1.8 and Swing version 1.1, so you do not need to have either the JDK or Swing already installed to make use of it. Unlike most GUI builders, SwingBuilder does not generate code from your user interface design. Instead, it saves either a compact binary representation of your component layout, or it can create an XML file. At runtime, software provided by SwingSoft and included with SwingBuilder reads either of these formats and recreates the user interface.

The CD-ROM contains an evaluation copy of SwingBuilder that was packaged especially for this book, in the SOFTWARE\SWINGBUILDER directory.

To install this software, Windows users should double-click or run the file sb2.exe. For Linux users, an RPM package is provided. To install this, use the command

 rpm -i SwingBuilder-2_0-2_noarch.rpm 

 

 



Core Swing
Core Swing: Advanced Programming
ISBN: 0130832928
EAN: 2147483647
Year: 1999
Pages: 55
Authors: Kim Topley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net