Introduction to JBuilder: User Interface & Project Management - Prof. Y. Daniel Liang, Study Guides, Projects, Research of Computer Science

An introduction to using jbuilder, a java ide. It covers the jbuilder user interface, including the appbrowser window, main menu, status bar, project pane, structure pane, and content pane. It also explains how to create and manage projects in jbuilder, including setting project properties and paths.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 08/04/2009

koofers-user-q0y-1
koofers-user-q0y-1 🇺🇸

10 documents

1 / 30

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
C:\idrive\web\introjb4\JB7Note.doc Last printed 7/17/2002 8:44 PM
CHAPTER
2
Getting Started with JBuilder
Assume you have successfully installed JBuilder on your
machine. Start JBuilder from Windows, Solaris, Linux, or
Mac. The main JBuilder user interface appears, as shown in
Figure 2.1. If you don't see the Welcome project, choose
Welcome Project (Sample) from the Help menu.
NOTE: The screen shots in this book are from
JBuilder 7 Personal. If you use JBuilder 7
Standard or JBuilder 7 Enterprise, your screen
may look slightly different. For example, Figure
2.2 shows the screen shot for JBuilder
Enterprise.
***PD: Please leave some space on top and bottom for labels.
Labels will be provided at Proof stage. Author.
Figure 2.1
9
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Introduction to JBuilder: User Interface & Project Management - Prof. Y. Daniel Liang and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

CHAPTER

Getting Started with JBuilder

Assume you have successfully installed JBuilder on your machine. Start JBuilder from Windows, Solaris, Linux, or Mac. The main JBuilder user interface appears, as shown in Figure 2.1. If you don't see the Welcome project, choose Welcome Project (Sample) from the Help menu.

NOTE: The screen shots in this book are from JBuilder 7 Personal. If you use JBuilder 7 Standard or JBuilder 7 Enterprise, your screen may look slightly different. For example, Figure 2.2 shows the screen shot for JBuilder Enterprise.

_PD: Please leave some space on top and bottom for labels. Labels will be provided at Proof stage. Author._*

Figure 2.

The JBuilder user interface is a single window that performs functions for editing, compiling, debugging, and running programs.

Figure 2.

The screen of JBuilder Enterprise looks slightly different from JBuilder Personal.

The JBuilder user interface presents a single window for managing Java projects, browsing files, compiling, running, and debugging programs. This user interface is called AppBrowser since JBuilder 3.5. Note that the AppBrowser window and the main window are two separate windows in JBuilder 3, but are combined into one window since JBuilder 3.5.

Traditional IDE tools use many windows to accommodate various development tasks, such as editing, debugging, and browsing information. As a result, finding the window you need is often difficult. Because it is easy to get lost, beginners may be intimidated. For this reason, some new programmers prefer to use separate utilities, such as the JDK command-line tools, for developing programs.

Borland is aware of the usability problem and has made a significant effort to simply the JBuilder user interface.

_PD: Need several labels for this figure. AU_*

Figure 2.

The project pane manages JBuilder projects.

  • A small toolbar with four buttons (Close Project , Add To Project , Remove From Project , and Refresh ).
  • A drop-down list of all opened projects.
  • A tree view of all the files that make up the active project.

The project pane shows a list of one or more files. The project (.jpx) file appears first. Attached to that is a list of the files in the project. The list can include .java, .html, text, or image files. You select a file in the project pane by clicking it. The content pane and the structure pane display information about the selected file. As you select different files in the project pane, each one will be represented in the content and structure panes. The project pane shown in Figure 2.3 contains three files. The Add button is used to add new files to the project, and the Remove button to remove files from the project. For example, you can remove Welcome.html by selecting the file in the project pane and clicking the Remove button. You can then add the file back to the project as follows:

  1. Click the Add button to display the Open dialog box shown in Figure 2.4.
  2. Open Welcome.html. You will see Welcome.html displayed in the project pane.

Figure 2.

The Open dialog box enables you to open an existing file.

TIP: You can select multiple files by clicking the files with the CTRL key pressed, or select consecutive files with the SHIFT key pressed.

2.5 The Content Pane

The content pane displays all the opened files as a set of tabs. To open a file in the content pane, double-click it in the project pane. The content pane displays the detailed content of the selected file. The editor or viewer used is determined by the file's extension. If you click the WelcomeApp.java file in the project pane, for example, you will see six tabs (Source, Design, Bean, UML, Doc, and History) at the bottom of the content pane (see Figures 1.1). If you select the Source tab, you will see the JBuilder Java source code editor. This is a full-featured, syntax-highlighted programming editor.

If you select Welcome.html in the project pane, you will see the content pane become an HTML browser, as shown in Figure 2.5. If you choose the Source tab, you can view and edit the HTML code in the content pane, as shown in Figure 2.6.

Figure 2.

You can edit HTML files in the content pane.

2.6 The Structure Pane

The structure pane displays the structural information about the files you selected in the project pane. All the items displayed in the structure pane are in the form of a hierarchical indexed list. The expand symbol in front of an item indicates that it contains subitems. You can see the subitems by clicking on the expand symbol.

You can also use the structure pane as a quick navigational tool to the various structural elements in the file. If you select the WelcomeFrame.java file, for example, you will see classes, variables, and methods in the structure pane. If you then click on any of those elements in the structure pane, the content pane will move to and highlight it in the source code.

If you click on the jMenuFile item in the structure pane, as shown in Figure 2.7, the content pane moves to and highlights the statement that defines the jMenuFile data field. This provides a much faster way to browse and find the elements of a file than scrolling through it.

Figure 2.

You can cruise through the source code from the structure pane.

CHAPTER

Creating and Managing Projects

A project is like a holder that ties all the files together. The information about each JBuilder project is stored in a project file with a .jpx file extension. (Prior to JBuilder 7, the project file extension is either .jpx or .jpr. The .jpr project files are still compatible in JBuilder 7.) The project file contains a list of all the files and project settings and properties. JBuilder uses this information to load and save all the files in the project and compile and run the programs.

3.1 Creating a Project

To avoid frustrating mistakes, it is important to create project in a consistent and uniformed way for all your programs. I recommend new users to create a project as follows:

Figure 3.

The Project wizard Step 2 of 3 enables you to modify project settings.

  1. Type c:/liang in the Output path field, c:/liang/bak in the Backup path field, and c:/liang in the Working directory field. In the Source tab, change the Default path and Test path to c:/liang. To do so, click the Edit button to display the Select Directory dialog box, as shown in Figure 3.3. Type c:/liang in the Directory field. If the directory does not exist, you will see the No Such Directory dialog box, as shown in Figure 3.4. Click Yes to return to Project Wizard - Step 2 of 3.

Figure 3.

You can select or specify a directory in the Select Directory dialog box.

Figure 3.

You can select or specify a directory in the Select Directory dialog box.

  1. Click Next in Project Wizard -- Step 2 of 3 to display Project Wizard -- Step 3 of 3, as shown in Figure 3.5. Fill in the title, author, company, and description fields. These optional fields provide a description for the project.
  2. Click Finish. The new project is displayed in the project pane, as shown in Figure 3.6. The Project wizard created the project file (tutorial.jpx) and an HTML file (tutorial.html), and placed them in c:\liang. The project file stores the information

Figure 3.

A new project is created with the .jpx file and .html file.

NOTE: JBuilder automatically generates many backup files. I use bak as the root directory for all these backup files so they can be easily located and removed.

CAUTION: Creating a project is a preliminary step before developing Java programs. Creating projects incorrectly is a common problem for new JBuilder users, and can lead to frustrating mistakes. You may create your project exactly as shown in this section and change liang to your name.

3.2 Managing Projects in JBuilder (Optional)

JBuilder uses a project file to store project information. You cannot edit the project file manually; it is modified automatically, however, whenever you add or remove files from the project or set project options. You can see the project file as a node at the top of the project tree in the project pane (see Figure 3.6). JBuilder uses a Project Properties dialog box for setting project properties and provides a Project wizard to facilitate creating projects.

NOTE: The project properties can be modified in the Project Properties dialog box after a

project file is created. However, there is no need to change any properties for using this book if you have set the path properties correctly in the Project wizard in JBuilder 7. That is why this section is marked optional.

3.2.1 Setting Project Properties

JBuilder uses the Default Project Properties dialog box to set default environment properties for all the projects. An individual project has its own Project Properties dialog box, which can be used to set project-specific properties. To display the Default Project Properties dialog box, select Project, Default Properties, as shown in Figure 3.7. To display the Project Properties dialog box, select Project, Properties, as shown in Figure 3.8. You can also right-click the project file in the project pane and choose the Properties command to display the Project Properties dialog box.

The Default Project Properties dialog box (Figure 3.7) and the Project Properties dialog box (Figure 3.8) look the same but have different titles. Both dialog boxes contain Paths, General, Run, Debug, and Code Style. The Team tab is only available in JBuilder Professional and Enterprise. You can set options in these pages for the current project or the default project, depending on whether the dialog box is for the current project or for the default project. JBuilder Professional and JBuilder Enterprise Edition have more options in the Project Properties dialog box.

Figure 3.

Each project keeps its own project properties.

3.2.2 The Paths Page The Paths page of the Project Properties dialog box sets the following options: [BL] JDK version.

[BL] Output path where the compilation output is stored.

[BL] Backup path where the backup files are stored.

[BL] Working directory where the temporary files are stored.

[BL] Source page where the source files are stored.

[BL] Documentation page where the source files are stored.

[BL] Required Libraries page where the libraries are searched for compiling and running.

JBuilder can compile and run against JDK 1.2, JDK 1.3, or JDK 1.4. To set up the list of available JDKs, click the Ellipsis button to display the Available JDK Versions dialog box for adding new JDK compilers. This feature is available

only in JBuilder 7 Standard and Enterprise.

Setting proper paths is necessary for JBuilder to locate the associated files in the right directory for compiling and running the programs in the project. The Source page specifies one or more paths for the source file. The Output path specifies the path where the compiler places the .class files. Files are placed in a directory tree that is based on the Output path and the package name. For example, if the Output path is c:\liang and the package name is tutorial in the source code, the .class file is placed in c:\liang\tutorial. The Backup path specifies a directory where the backup source files are stored. JBuilder automatically backs up the files before committing any change to the current file. Note that the .java files are backed up in the backup directory, but the other files, like .html and .jpx, are backed up in their original directory. All the standard JDK libraries are already preinstalled. If you need to add the custom libraries to the project, click the Add button to display a list of available libraries. To remove a library, click the Remove button. To switch the order of libraries, use the Move Up and Move Down buttons.

3.2.3 The General Page

The General page (Figure 3.9) allows you to specify an encoding scheme used in JBuilder, enable or disable automatic source package discovery, and modify javadoc fields.

Figure 3.

The Build page sets compiler options.

The option "Include debug info" includes symbolic debug information in the .class file when you compile, make, or rebuild a node. The option "Show warnings" displays compiler warning messages. The option "Show deprecations" displays all deprecated classes, methods, properties, events, and variables used in the API. The option "Synchronize output dir" deletes class files on the output path for which you do not have source files before compiling.

The Option "Check stable packages" checks files in the packages marked "stable" to see whether they and their imported classes need to be recompiled. This option shortens the edit/recompile cycle by not rechecking stable packages.

The option "Make stable package" checks all the classes of a package on the first build and marks the package "stable." If this option is unchecked, only the referenced classes of this package will be compiled, and the package will not be marked "stable." This option should be unchecked when working with partial projects. It is especially useful for working with a library of classes with no source code.

The option "Obfuscate" makes your programs less vulnerable to decompiling. Decompiling means to translate the Java bytecode to Java source code. After decompiling your obfuscated code, the generated source code contains altered symbol names for private symbols. This feature is available only in JBuilder Professional and Enterprise.

The "Exclude Class" choice lets you specify that a .class file is excluded from being compiled. This feature is available only in JBuilder Standard and Enterprise.

The option "Autosave all files before compiling" automatically saves all files in the project before each compile.

The option "Generate source to output path" is applicable only to RMI (Remote Method Invocation) and IDL (Interface Definition Language) files. These files are used in multi- tier Java applications.

3.2.5 The Code Style Page

The Code Style page (Figure 3.11) enables you to specify the code style of the program generated by JBuilder.

Figure 3.

The Code Style page of the Project Properties dialog box sets the options for the code style of the program generated by JBuilder.

With the option "End of line" selected, JBuilder will generate the code with opening braces inserted at the end of the line; otherwise, the opening braces are inserted at the beginning of the new line.

In the Event Handling section, you can choose one of the options to tell JBuilder to generate event-handling code using an anonymous adapter, a standard adapter, or matching the existing style of event-handling code. The adapters are used in the UI designer in JBuilder. For more information on adapters, please refer to Chapter ?, "UI Designer.’’

The option "Use Beans.instantiate" tells JBuilder to instantiate objects using Beans.instantiate() instead of the new operator. This feature is related to JavaBeans and is discussed in my book Rapid Java Application Development Using JBuilder 4/5/6/7, Second Edition.

3.2.6 The Editor Page

The Editor page (Figure 3.12) sets the end of line characters in the editor. The end-of-line characters are