Chapter 54
Symantec Café

by Bill Rowley

As one of the earliest (and best-priced) commercially available Java-integrated development environments, Symantec's Café quickly became quite popular. Along with that popularity, though, comes a reputation as a product that is difficult to learn. By exploring the features and capabilities of Café, this chapter can help you jumpstart your Java programming using Café.

The purpose of this chapter is to explain the usage and customization of Café. Do not expect any Java code fragments or Java applets--there won't be any.


NOTE: Even though this chapter focuses solely on Café, you can still learn Java with the help of Café. First follow the instructions in the remainder of this chapter to obtain, install, and start Café. With Café running, choose Help, Intro to Java Programming, and then follow the built-in tutorial.


Welcome to Café

Okay, you've heard a lot about Java and its potential. You thought "Hey! I can do that!" and you downloaded a copy of the Sun Java Development Kit (JDK). You wrote a Java program or two using a text editor (like Notepad or Wordpad) to key in the source and the JDK command-line interface to compile and run it. You may even have tried to use the JDK debugger. Now you're frustrated and asking yourself, "What's the deal here? Java on the Net is so cool, but programming in Java is a real drag! There must be a better way!" Well, there is a better way and it's shown in Figure 54.1. Welcome to Symantec Café.

FIG. 54.1
Start enjoying Java at Café!

What Exactly is Café?

Café is an Integrated Development Environment, or IDE, specifically designed for use with the Java language. An IDE is a set of tightly coupled tools that work together to help programmers write, compile, test, and manage programs and projects. Café is available for the Windows 95, Windows NT, and Macintosh operating systems.


NOTE: The instructions and examples given in this chapter apply to the 1.51 version of Café for Windows 95/NT.




As noted previously, an IDE consists of a group of tools that work together to assist the programmer in his development tasks. Table 54.1 lists the major components that make up Café, along with a brief description of each one.
Table 54.1 Components of Cafª
Component Description/Usage
Toolbar The main control of Café. It provides access to all of the other components.
Workspaces Tabbed folders of pre-defined window layouts.
AppExpress Project-starting wizard that walks you through the creation and file setup of a new Java project.
Café Studio Easy-to-use visual designer for creating graphical user interfaces to your Java programs.
Project Manager Graphically organizes and manages source files associated with a project.
Source Editor Full-featured text editor for adding or modifying Java code or HTML.
Class Editor Three-paned window that graphically organizes classes, class members, and the source code of the class members.
Hierarchy Editor Displays and lets you edit class relationships in a tree diagram.
Compiler Symantec's own optimized Java compiler.
Debugger Lets you visually trace and manipulate Java programs as they execute.
Expression Evaluator Calculates the value of a Java expression from within the Source, Data, or Inspector Views of the Debugger.
Just-In-Time Compiler Speeds Java execution within Café and the AppletViewer by converting Java bytecode into platform-native code.
Parser Running in a background thread, the Parser tracks changes in the source code so that each component is always using the current code.
Help Standard Windows-type, context-sensitive help files.
JDK Sun Microsystems Java Development Kit Version 1.0.2.

Where Can I Get Café?

Like many Web-related products, you have several choices of where to purchase Café. Symantec sells Café on CD-ROM through computer stores, mail-order outlets, and just about anywhere else that software is sold. Café can also be purchased electronically and downloaded through the Internet. Current retail price per copy is between $100 and $130 U.S. dollars.


NOTE: Because Symantec uses the familiar InstallShield utility to install Café on your system, this chapter does not include installation details.


Internet Purchase One benefit of buying Café through the Internet is that it insures that you receive the most current version. To purchase a copy of Café through the Internet, follow these steps:
  1. Point your Web browser at the Café home page, http://cafe.symantec.com.

  2. Click the link labeled Café for Windows 95/NT (or Macintosh) to take you to the index page.

  3. Click the link labeled Online Purchase & Update Center to take you to the Subscription Center.

  4. Click the link labeled Purchase Café and then follow the instructions.


NOTE: Life (and hypertext links) on the Internet moves at a very fast pace and is subject to change without notice. Should Symantec decide to change their Web site these instructions may no longer be completely accurate. That's why these instructions include few direct URL addresses.




CD-ROM
If you bought Café on CD-ROM, the odds are good that the version on the CD is 1.0. This first release version is not very stable and has other strange quirks that make it difficult to use. Of course, you can always check the box labeling or the CD-ROM for the version number, but the best way is to check the installed software itself. Here is how to determine the version of Café that you have:
  1. Start Café.

  2. Choose Help, About Symantec Café. The Café Logo box appears (refer to Figure 54.1).

  3. Look for the Symantec Café - Version x.xx near the bottom of the logo box.

As of this writing, the most current release version is 1.51. Don't worry if you have a prior version because, along with Café, you also receive a one-year subscription for updates and fixes from Symantec. In the package with the CD-ROM should be a card that explains the Subscription Center and lists the User ID and Password assigned to your copy of Café.

To upgrade your version of Café, following the instructions listed under the "Here's how to access the Subscription Center at Java Central" heading on the card won't help you much since they are probably wrong. Try this instead:

  1. Follow Steps 1 through 3 of the instructions listed in the "Internet Purchase" section to access the Subscription Center.

  2. Click the link labeled Update Center and follow the instructions to register your copy of Café and access the download area of the Subscription Center.


TIP: Make a copy of the subscription information card (or at least the User ID and Password). Store it somewhere that it will be safe (and where you will be able to find it later).


Controlling Café

Now that you have installed or upgraded to the most current version, it's time to learn about Café's tool set. This section familiarizes you with the basics of the tools that control Café itself: the Toolbar and the Workspace. Each section also shows you how to customize the controls to match the way you prefer to work.


TIP: You'll learn much more from the remainder of this chapter if you have Café up and running while you read this book.


The Toolbar

The first window that opens when Café is started is the toolbar (or main window), as shown in Figure 54.2. The toolbar, which opens along and across the top of the desktop, provides access to, and control of, the other components of Café. The remaining desktop area is left available for the Workspace.

FIG. 54.2
Café's Toolbar provides a central point of control for Café's components.

Looking at Figure 54.2, you can see that the toolbar is divided into four sections:

The Menu Bar The menu bar should be familiar to anyone who has ever used a Windows-based application. Listed across the menu bar (shown in Figure 54.3) are the major menu items of the Café main menu. When you click an item, the item's drop-down submenu appears. Most of the menu items and their submenus are self-explanatory.

FIG. 54.3
Café's Menu bar lets you access each of Café's major controls and their submenus.


TIP: Browsing through the menu items and their submenus now can help you perform the tasks presented in the "Customizing the Toolbar and Other Tricks" and "The Workspace" sections later in the chapter.


The Workspace Toolbox The Workspace Toolbox (see Figure 54.4) appears as a set of labeled file folder tabs. Each tab represents a pre-defined set of attributes that determine how the Workspace will be configured. Four preset tabs--Editing, Browsing, Debugging, and Output--are delivered with Café. As you see later in the Workspace section, each of the tabs can be customized and additional tabs can be created.

FIG. 54.4
Café's Workspace Toolbox lets you choose a Workspace configuration by clicking the folder tabs.

The Build Toolbox Made up of five icon buttons, the Build Toolbox (see Figure 54.5) gives you control over the building and compiling of Java projects and programs.

FIG. 54.5
The Build Toolbox is where you find the buttons that let you build, compile, or test your Java code.

Moving from left to right, the buttons on the Build Toolbox include:

  • Compile File. Invokes the built-in Symantec Java compiler for the active program.

  • Build. Performs a build on the active program.

  • Rebuild All. Performs a build on all the programs within the active project.

  • Stop Build. Interrupts a build that is in progress.

  • Execute Program. Runs the compiled program.


NOTE: Building versus compiling--what's the difference? Very simply put, compiling is converting the Java program source code into a class file. Building is a process that not only compiles the Java source code of the active program but also any other program that needs re-compilation to reflect changes made to the project.




The Views Toolbox
The Views Toolbox provides a drag-and-drop method of opening Café component windows on your desktop. First, look at the Views Toolbox in Figure 54.6 and see what each icon does.

FIG. 54.6
Quick access to each of Café's component windows is provided by the icons on the Views Toolbox.

Again moving from left to right, the icons on the View Toolbox include:

  • Source
  • Project
  • Call
  • Data
  • Inspector
  • Thread
  • Breakpoint
  • Output
  • Class Editor
  • Hierarchy Editor

The icons on the Views Toolbox are not buttons; single-clicking them will do nothing. There are two ways to use the icons:

  • Double-click the View icon to launch its component (open its window in the Workspace area).
  • Drag-and-drop the View icon onto the Workspace to launch its component.

Double-clicking the View icons launches the component but the component's window (called a View) may open on top of another component's window. Use the drag-and-drop method if you want the component window to open at a particular location within the Workspace. You identify the location by dragging and then dropping the View icon onto the Workspace where you want the upper-left corner of the component window.


NOTE: From here on, the term View is used to refer specifically to Café's component windows available through the Views Toolbox.




Customizing the Toolbar and Other Tricks
Now that you know what features and controls are available on the Café toolbar, it's time to learn how to customize the toolbar so that it works best for you.

Start with the Menu Bar All but one of the menu items on the menu bar are standard and integral to Café so you cannot change them. The one exception is the Tools menu item. Café allows you add other applications you might want to run to the pull-down submenu of the Tools menu. Follow these steps to edit the Tools item of the menu bar:

  1. From the menu bar, choose Tools, Settings to open the Tool Settings dialog box as shown in Figure 54.7.


    FIG. 54.7
    Use this dialog to customize your
    Tools Menu.

  2. Click an existing Tools Menu entry to move, delete, or modify it. If you are only modifying an existing entry, just type over the attributes you are changing and skip to Step 4.

  3. Click the appropriate button for Move Up, Move Down, Delete, or Add.

    Move Up. Moves the selected tool toward the top of the list.

    Move Down
    . Moves the selected tool toward the bottom of the list.

    Delete. Removes the tool from the list.

    Add
    . Opens a standard Windows Add dialog box. Use the dialog box to browse for the application you are adding. Once you find the application program, double-click it to bring it into the Tool Settings dialog box.

  4. Click OK to save your changes and exit, or click Cancel to discard your changes and exit.

Now the Toolboxes Remember the terms floating, dockable, and iconographic from the introduction? Well, these terms all describe characteristics of the toolboxes. Start Café and follow along:

  1. Place the mouse pointer somewhere on the frame surrounding the Build Toolbox.

  2. Using the mouse, click and drag the toolbox a few inches down from the toolbar and drop it anywhere on the screen below the toolbar, as shown in Figure 54.8.

    FIG. 54.8
    The undocked Build Toolbox is now a floating window.

    Congratulations, you've just undocked the toolbox and changed it into a floating window! Floating windows always stay on top of other windows regardless of which window is active, so they don't disappear. While you have it undocked, trying moving the toolbox around. You can also re-size the toolbox windows by grabbing and dragging the toolbox window frame.

  3. Now right-click the mouse on the Build Toolbox window frame. A pop-up menu, like the one in Figure 54.9, appears.

    FIG. 54.9
    Use this menu to change the settings of the toolbox.

    The first entry on the pop-up menu, Dockable, controls how the toolbox window will behave when it is dropped onto the toolbar window. With Dockable selected (indicated by the check mark), the toolbox window re-integrates itself into the toolbar when dropped back onto the toolbar.


    TIP: To keep the window floating even when dragged onto the toolbar, make sure that Dockable is not selected.


    You can set the size of the icons, tabs, or buttons on the toolbox by selecting one of the next entries: Small, Medium, or Large.

    The last entry, Reset Palette, restores any icons or buttons (but not tabs) that have been removed from the toolbox.


    CAUTION
    Don't try this at home kids! Before you try to remove icons or buttons, consult the Café Help files.

  4. Drag the Build Toolbox back onto the toolbar window and drop it on the far left side of the toolbar.

The toolbar should now look like Figure 54.10.

FIG. 54.10
Dropping the toolbox onto the left of the toolbar shifts the other toolbars to the right.


TIP: If the toolbox did not re-dock itself into the toolbar, check the Dockable setting using the Toolbox pop-up menu. The toolbox will not re-dock unless Dockable is selected.


Try different toolbar configurations as you work with Café. Experiment with icon and button sizes and with toolbox locations. Once you find a configuration you like, you can preserve it by choosing File, Exit & Save All.


TIP: If you over-experiment and configure things beyond all recognition, don't panic! You can restore the settings to sanity by choosing File, Exit & Discard. You can then restart Café and begin again.


The Workspace

In previous sections of this chapter, you have seen many references to the Workspace and are probably wondering just what it is.

If you tried the Workspace toolbox in the previous section, you saw that clicking the different tabs of the Workspace toolbox changed the configuration of the Café views on your desktop. Each tab displayed a specific set of views in a specific layout. Several of the same views appear in multiple tabs but are presented in different locations and/or sizes depending on which tab is active.

These preset configurations of views, their sizes, and locations, are called Workspaces. A Workspace can occupy all of your desktop that is not covered by the Café toolbar. Because the Workspace is wide-open in this manner, Café lets you arrange its views in a way that best matches your work style.

You can create, clone, delete, rename, or re-configure the Café Workspaces.


TIP: After you complete this section, spend some time configuring your Workspaces. Set them up to match the way you like to work. Time spent doing this now will save you time and frustration later.




Re-Configuring a Workspace
Start by re-configuring the Editing Workspace in three easy steps:
  1. Click the Editing tab of the Workspace toolbox. Your desktop should look something like the one shown in Figure 54.11. Don't worry if it is not exactly the same because you will be changing it.

    FIG. 54.11
    A Source Editor window, a Project Manager window, and an Output window make up the View configuration of the Editing Workspace.

  2. Re-position and re-size the views to match the example shown in Figure 54.12 or in any way you prefer. Use standard Windows techniques (such as grabbing and dragging the window frame to resize it and so on) to manipulate the views.

    FIG. 54.12
    In this example of the Editing Workspace the Source Editor window has been shortened to match the height of the Project Manager win-dow and the Output window has been stretched to the full width of the screen.

  3. Save the Editing Workspace configuration by choosing Environment, Workspace, Save Workspace Set.


NOTE: Before you begin making changes, be assured that you can back out of any changes you make by choosing Environment, Workspace, Reset. This procedure restores the Workspace settings to their values at the time of the last save. Therefore, if you perform a save more than once, you cannot go back to the original settings.




Creating and Cloning Workspaces
See! It's really that simple. You can also create your own workspace (either from scratch or by cloning an existing workspace) for special tasks or just to have an alternate configuration available. Now try creating a new workspace:
  1. Choose Environment, Workspace, New (or Clone if you want to use the current Workspace as a template). The Workspace Name dialog box appears (see Figure 54.13).

    FIG. 54.13
    Enter a name for a new or cloned Workspace.

  2. Type in the name of your new Workspace and click OK.

  3. Configure the new Workspace using the techniques you learned earlier in this chapter. You may want to re-dock the floating toolboxes, open views, size and position them, and more.

  4. After you finish configuring the Workspace, remember to save its settings. (See Step 3 of the section "Reconfiguring a Workspace" for details.)

Renaming a Workspace To be truly useful, a Workspace's name alone should provide an instant clue to the configuration and function of that Workspace. If you have made major changes to a Workspace configuration (or if you would just prefer a different name) you can rename the Workspace to better reflect its purpose. To rename a Workspace:

  1. Select the Workspace to be renamed by clicking its tab in the Workspace toolbox.

  2. Choose Environment, Workspace, Rename to call up the Workspace Name dialog box (refer to Figure 54.13).

  3. Type in the new name for the Workspace and click OK to apply the new name.

Deleting a Workspace Deleting a Workspace is even easier than creating, renaming, or re-configuring one. Just follow these steps:

  1. Select the Workspace to be deleted by clicking its tab in the Workspace toolbox. Be sure you have selected the right one, because Workspaces are deleted without confirmation.

  2. Choose Environment, Workspace, Delete; the Workspace is gone.

AppExpress

To work on a project within Café effectively, you need several files:

  • A Café project file (extension PRJ) that defines the other files that belong to the project.

  • One or more Java source files (extension JAVA) to contain the Java source code.

  • A resource file (extension RC) that contains the parameters Café Studio uses to define the project's GUI. (This file is not required for projects that will not use a GUI.)

  • An HTML file (extension HTML) that provides parameters necessary for AppletViewer to execute an applet. (This file is not required for projects that will not use a GUI.)

To create these files and establish a framework for working within Café, you use the AppExpress. AppExpress is an easy-to-follow set of dialog boxes that step you through the creation of a Café project.

Choose Tools, AppExpress to call up the AppExpress dialog box (shown in Figure 54.14).

FIG. 54.14
Use the AppExpress dialog box to create a Java project within Café.

Now step through each page of the AppExpress by filling in the information and clicking the Next button.


TIP: When specifying the application type within the AppExpress, keep in mind these definitions:


  • Applet. A Java program intended to be run within in a Web browser or AppletViewer with an applet's security restrictions.

  • Stand-alone application. A Java program intended to run outside of the Web browser environment. A stand-alone application has less restrictive security constraints than an applet.

  • Console application. A Java program intended to run from the command line without interacting with the user through a GUI.

Once you reach the Help Options screen, click the Finish button to apply your choices and to create the project. Prior to clicking the Finish button, you can click the Previous button to page back through the dialog and make changes or just review your choices. At any stage of the dialog, you can click the Cancel button to close the AppExpress dialog box and cancel the creation of the project.


NOTE: Even though AppExpress presents the Help Options screen, this version of Café does not allow you to specify any help options.


Cafés Project Manager and Editors

Every programmer knows that manually tracking the parts of a project adds unnecessary time and effort to the project. Similarly, a weak editor reduces programmer productivity when the programmer has to fight to write the code. This section introduces you to Café's answer to these problems--the Project Manager and the Source, Class, and Hierarchy Editors.


TIP: Include using the Project Manager and the editors in your practice sessions with Café. Trying them out is the only way you can assess which of the tools works best for you.


The Project Manager

When you ran the AppExpress, you created the files needed by Café to effectively work on the new project. The Café Project Manager helps you organize the member files of your project and lets you control the editors. Figure 54.15 shows Café's Project Manager with one of the sample Java applets loaded.

FIG. 54.15
Organize your project's files in the Project Manager.

The folder in the left pane of the Project Manager window represents the current project. Right-clicking the project folder invokes the pop-up menu for the project management functions, such as Create Subproject, Build, Rebuild All, Parse All, Edit Project, and Settings. The Project Settings option opens the Project Settings dialog box. Most of the project settings won't need to be changed, especially if you used AppExpress to create the project. One setting you will want to change, when your program is completed, is the Debug/Release property. Set to Debug, Café compiles your programs with additional hooks for the Café Debugger to use. You should set this to Release and re-compile before putting your applet/application into a production environment.

The files listed in the right pane are, of course, the files that make up your project. Each file lists its name, file extension, a parsed indicator, and date and time modified. You can sort the files by any of the columns shown by clicking the column heading button. For example, to sort the files shown in Figure 54.15 by file extension, you click the column heading button marked "Ext." Right-clicking this side of the Project Manager window invokes the pop-up menu for the file management functions: Compile, Mark as Main, Remove, Attributes menu, Don't Show menu, and Settings.


TIP: You can open a file in the Source Editor by dragging it from the Project Manager and dropping it onto the desktop, Workspace, or the Source Editor window. To open the file in the Class or Hierarchy Editor, drop it onto an open Class or Hierarchy Editor window.


The Source Editor

The Café Source Editor is a true programmer's editor. Along with the standard new, open, save, cut, paste, search and replace, and print functions available in most editors, Café offers powerful tools such as macros, color-coding of text, automatic indenting, and file comparison. Figure 54.16 shows the Café Source Editor in its full glory.

FIG. 54.16
Editing is easy using Café's powerful Source Code Editor.

Across the top of the Source Editor window is a menu bar with the self-explanatory File, Edit, Goto, Macro, and New! menu items. As usual, clicking a menu item activates its drop-down submenu. Below the menu bar is a button bar with icon buttons for each of the most often used functions available through the menu bar. From left to right the icon buttons are: New Text, Open File, Save, Cut Text, Copy Text, Paste Text, Print, Find, Find Previous, Find Next, and Play Default Macro.

Notice the different colors of the text in the Source Editor: Comments are red, Java keywords are blue, and all other text is black. Also take note of the indenting. The color-coding and indenting are both done automatically while you type your code. This makes finding syntax errors, such as improperly closed comment blocks and misspelled keywords, a snap.

The Source Editor's properties like text colors, auto-save, and undo buffer size can be accessed and customized through the Editing/Browsing Settings dialog box (see Figure 54.17). You call up this dialog box by choosing Edit, Text Settings.

FIG. 54.17
Adjust the editor's properties to suit your needs.

By now you should be familiar enough with Café in particular and source editors in general that reviewing every feature here would not be especially helpful. However, there is one feature that is worth special mention--the Compare facility. With the Compare facility you can match a source file against a backup copy to identify the changes or even compare the output files from different executions of a Java application. The Compare Files dialog box, shown in Figure 54.18, is invoked by choosing File, Compare.

FIG. 54.18
Specify the files to be compared in this dialog box.

Type in (or browse) the names of the files to be compared, specify how you would like the output displayed (horizontal or vertical) and which line numbers to start the compare with, and click OK. See Figure 54.19 for an example of the compare result.

FIG. 54.19
Source lines that differ are highlighted in this sample comparison.

The Class Editor

Wouldn't it be great if you could edit the relationship, members, and source code of a Java class all from one place? Yes, it would and Café's Class Editor, shown in Figure 54.20, allows you to do just that.

FIG. 54.20
Edit a Java class's relationships, members, and source in one window--the Class Editor.

The Class Editor's three pane layout displays the classes and their relationships in the upper-left pane, the class members in the upper-right pane, and the class source code in the bottom pane. Double-click a class name in the Classes pane to display the methods and data in the Members pane. The methods and data are arranged in a collapsible hierarchy. Double-click a method or data item to display the Java source code for that method or data item.


NOTE: You can right-click any of the panes to access the pop-up menu appropriate for that pane.


The Hierarchy Editor

With all of the other Café tools, and the wide amount of Java base class documentation, the Hierarchy Editor doesn't really seem necessary. But if you are working with a large project and you want a really neat tool to manage your project's class relationships, the Hierarchy Editor, shown in Figure 54.21, is it. Fully parsed Java-base classes and your project's classes are graphically displayed in a scrollable window that shows each class name with lines connecting them by ancestry.

FIG. 54.21
Visualize and edit class relationships with the Hierarchy Editor.

Within the Hierarchy Editor you can open a class in the Class Editor by double-clicking its name. To add a derived, top, or sibling class, or to connect to a base class, right-click the class name and choose from the pop-up menu.

Café Studio

Café Studio's ability to visually create GUIs by simply pointing-and-clicking and dragging-and- dropping, without having to handcraft any Java source code, is one of Café's biggest selling points.

Café Studio is the easiest to learn, most user-friendly, and most intuitive component of Café. The online Help files for Café Studio are very well organized and complete.

But for reasons known only to Symantec's development team, Café Studio is also virtually impossible to find and start.

Because of Café Studio's ease-of-use and better-than-average documentation, this section does not provide great detail on Café Studio itself. Instead, this section tells you about the "gotchas" of Café Studio and gives you the work-arounds. And of course, how to start Café Studio.

Starting Café Studio

Go ahead and try to find and start up Café Studio. Did you try? Good job if you found and started it. Don't feel bad if you couldn't; it's hidden very well.


NOTE: Café Studio stores parameters that define your GUI in a resource file (extension RC). The Java source code to support the GUI is written into the same source file (extension JAVA) that you edit in Café.




There are actually two ways to access Café Studio. First is through Café itself. With a project open in Café, choose Resource to open the Resource submenu.

Choose one of these entries from the Resource submenu:

  • New. Starts Café Studio with an empty resource file.

  • Open. Starts Café Studio with a standard Windows Open File dialog box for you to select the resource file.

  • Edit. Starts Café Studio using the project's resource file.

  • Settings. Does not start Café Studio, but opens the Resource Settings dialog box.

If you chose Open (and answered the Open File dialog box) or Edit, you should see the Café Studio Resource Browser as shown in Figure 54.22.

FIG. 54.22
Start designing with the Café Studio Resource Browser.

If you chose New, you should see the same Café Studio Resource Browser with a Create Resource dialog box (see Figure 54.23).

FIG. 54.23
Create a new GUI resource with the Create Resource dialog box.

The second way to start Café Studio is to run it as a stand-alone application apart from Café. To do this using Windows Explorer, double-click the CafeStudio executable found in the CAFE\BIN directory. Or you can invoke it from the Run selection of the Windows95 Taskbar.


TIP: You can add Café Studio to the Tools menu as described earlier in the section "Customizing the Toolbar and Other Tricks." This lets you launch Café Studio as a stand-alone application from within Café itself.


Gotchas and Work-Arounds

Here are a few of the known "gotchas" in Café Studio and how to work around them:

  • Café Studio Resource Browser window won't fully expand to fit the screen, even when maximized.
Work-around: Without maximizing the Resource Browser window, drag it to the top of your screen. This exposes a re-size handle on the bottom-right of the window. Grab the re-size handle and drag it to stretch the window as large as you like it.
  • After you invoke the FormExpress dialog box (used to create a new form resource), you must complete the operation. There is no Cancel or Close option.
Work-around: If you accidentally invoke the FormExpress dialog box, you still must complete the operation. To minimize damage to your project, select New Class and enter a bogus name such as DarnIT and click OK. This creates the resource which you then use the Cut button to remove. Go back into Café's Project Manager and remove the DarnIT.java file from the project. Finally you must delete the DarnIT.java file from the project directory.
  • After you invoke the MenuExpress dialog box (used to create a new menu resource), you must complete the operation. There is no Cancel or Close option.

    Work-around: Same as the work-around for the FormExpress gotcha.

Cafés Debugger

Using the Café Debugger may appear difficult at first, but once you learn the basics you should have no trouble at all. This last section provides an overview of Café's Debugger by leading you through a brief demonstration. Pay close attention because there will be a test--the first time you try debugging on your own.


NOTE: The sample applet CardTest is used to conduct this demonstration. The demonstration presumes that the project has been loaded and built.


You begin debugging a project by choosing Debug, Start/Restart Debugging or by pressing the F4 key. Café loads its Debugger and switches to the Debugging Workspace, as shown in Figure 54.24.


TIP: When working with a program that has breakpoints set from a previous session, pressing the F5 key will start the Debugger and run your program up to the first breakpoint encountered.


If you look carefully at Figure 54.24, you see that a new toolbox is on the toolbar. This is the Debug toolbox, shown close up in Figure 54.25.

Let's quickly see what each button on the Debug toolbox does:

  • Restart Debugging Ends the current debug session and restarts at the beginning of the program

  • Stop Debugging Ends the debug session

  • Toggle Breakpoint Flags or un-flags the current line of source code as a place to stop when execution reaches it

  • Set Breakpoint Flags the current line of source code as a place to stop when execution reaches it

  • Clear All Breakpoints Removes all breakpoints from the program

  • Step Into Executes the current line of source code

  • Step Over Moves to the next line of source code without executing the current line

  • Go Until Breakpoint Executes the program without stopping up to the next breakpoint

FIG. 54.24
Exterminate bugs with the Café Debugger.

FIG. 54.25
The buttons on the Debug toolbox let you control the Café Debugger.

Except for Restart Debugging, none of the Debug toolbox buttons are active unless your program is executing. You must start (or restart) debugging before they will have any effect.


TIP: You can also set and clear breakpoints when the program is not executing by using the pop-up menu within the Source Editor window. Activate the pop-up menu by right-clicking your mouse on the target line of code.


Now that you have the Debugger running and know more about the Debug toolbox, set a breakpoint and step through some code. First, set the breakpoint:

  1. Select the source code line within the Source Editor window using the mouse.

  2. Click the Set Breakpoint button from the Debug toolbox. The red dot to the left of the code line indicates that the breakpoint is set, as shown in Figure 54.26.

FIG. 54.26
CardTest.java with debugging Break- point set.

Now click the Go Until Breakpoint button to execute the program up to, but not including, the first breakpoint. The next line of code to be executed is marked by a small black arrow to the left of the line (see Figure 54.27). Notice that the AppletViewer starts up but, because you set the breakpoint before any paint or show operation, AppletViewer has nothing to display.

FIG. 54.27
Debugger has stopped at the breakpoint.

Also note the pop-up box within the source code. This box is a Value Tip. While debugging, you can use Value Tips to quickly find out the value of a variable, as long as the variable is within the scope the line be executed. Simply pause your cursor over a variable within the Source view and the Value Tip will appear.


TIP: You can adjust the amount of time the cursor must be on the variable before the Value Tip appears, or turn them off and on using the Debug Settings Dialog. Choose Debug, Settings, and the General tab to access the Value Tip controls.




To execute the next line of code, click the Step Into button of the Debug toolbox. Each click of the Step Into button executes another line of code.

Take a look at Figure 54.28. There are now three Source Editor windows cascading towards the bottom-right of the screen. Look closely at the file names in the title bar of each Source Editor window. These files are the java.lang package's source code itself. Thanks to Café's background parsing, you can step through the Java package sources included within your code as well as your code. Unless you plan to modify the Java packages, or you really want to know how they work, this feature won't help you too much. You can avoid stepping through all the Java package code by setting more breakpoints and clicking the Go Until Breakpoint button from the Debug toolbox.

FIG. 54.28
Source Editor windows cascade as you step through the java.lang package source code.

Go ahead and step through some lines of code. Watch these areas of the Debug Workspace as you do:

  • Data/Object window. Watch it change as it displays the data and objects within the current scope. Try using the different items from the View menu within the Data/Object window menu bar.

  • Call window. Follow the path used to reach this point of execution.

  • Breakpoint window. Track which classes have breakpoints set and which breakpoints have been reached.

  • Output window. Look here for error messages and any lines written to the Java Console.

  • Thread window (not shown). Monitor and control the state of any threads running within the program.

Visual Café

Imagine the best of Café's tools brought together with a visually oriented development tool. An environment that allows you to build Java applications simply by dragging and dropping visual elements onto a form. One where object interactions are defined just by pointing and clicking. This vision is the promise of Symantec's Visual Café.


NOTE: As of this writing Visual Café is not yet available as a production quality release. The information and examples shown here are based the Preview Release 2 version (see Figure 54.29) and therefore subject to change. Even though the Visual Café preview is available for download, Symantec recommends using Café for important development work until the production version of Visual Café is released.




FIG. 54.29
Symantec's next Java generation--Visual Café!

Despite the Café family name, Visual Café takes a different approach to Java development. Café itself centers on the creation and testing of Java code, with the building of the GUI handled separately by Café Studio. With Visual Café the focus is on the concurrent, interactive development and testing of the GUI and the supporting Java code. By stepping you through the building of a Java applet, this section will introduce you to these new features and functions of Visual Café:

  • Integrated form editor--similar to Café Studio's, lets you build windows, frames, and dialogs by dragging and dropping components onto the form.

  • Property List window--used to display and edit the attributes of each object within a project.

  • Component Library--stores and organizes objects such as forms, AWT and custom components, menus and menu items, and project templates.

  • Component Palette--provides quick drag-and-drop access to the objects in the Component Library.

  • Interaction Wizard--steps you through the definition of interaction between objects.

The VCafeTest applet used in this example will consist of a single window with three components:

  • A TextField AWT component.

  • Two AWT Button components--one to initialize the TextField and one to clear the TextField.

When started, the VCafeTest applet will display an empty TextField and two buttons. When clicked, the SayIt! button will display a message in the TextField. Clicking the Quiet! button will clear the message from the TextField. True, this applet may seem rather dull, but its purpose is to demonstrate the capabilities of Visual Café, not to win awards.

Create the Project

Much like Café, the first step in building an applet using Visual Café is to create the various files that Visual Café uses to enable you to build your applet. These files are grouped together under a project name. With Visual Café running, perform these steps to create and name your applet:

  1. Choose File, New Project, to open the New Project Template Dialog shown in Figure 54.30. Displayed in the dialog are the three templates delivered with Visual Café--Empty Project, Basic Application, and Basic Java applet.

    FIG. 54.30
    Create the new project by selecting a project template from the New Project Template Dialog.

  2. Select the project template by clicking the icon labeled "Basic Java applet with blank form" and then click the OK button to create the project's files and to open the Edit Workspace. Just like Café, Visual Café also uses the concept of workspaces to arrange the multiple windows used when working within Visual Café. Looking at Figure 54.31 you can see that the screen is pretty cluttered, but keep in mind that you are seeing a preview release of the product.

    FIG. 54.31
    Visual Café's Edit Workspace contains a window for project management, a form editor, and, hidden under the form editor window, an object property list.

  3. Bring the Property List for the applet object to the front by choosing Window, Property List or by pressing Ctrl+Shift+P.

  4. Scroll down through the applet object attributes and click the Name entry to open the Name value for editing.

  5. Key in the applet name (VCafeTest) as shown in Figure 54.32 and press enter.

    FIG. 54.32
    Use the Property List for the applet object to name the applet.

  6. Name and save the project. From the menubar choose File, Save As, to open the standard Windows Save As dialog. Key in the project's file name and click Save.

That's it! You've created and named the project and its applet.


NOTE: This preview version of Visual Café does not update all of the project files with the changed applet name. The example1.html file must be updated manually to reflect the new applet name or the AppletViewer and the Debugger will not work. To edit the example1.html: Right-click the mouse on the example1 file in the Project Window and choose Edit Source from the pop-up menu. Change the applet tag to match the name of your applet.


Create the GUI

Now that you have established the project and its supporting files, it is time to compose and create the GUI for the applet. As stated earlier, the VCafeTest applet will only have three components--the AWT TextField component and two AWT Button components. Start by adding the TextField component:

  1. Click the Standard Tab of the Component Palette (refer to Figure 54.31) to expose the Visual Café standard AWT components.

  2. Click and drag the TextField component onto the Form Editor window and drop it where you would like to place the component.

  3. Use the centering tools from the Form Editor toolbox to move the TextField component to the top-center of the form.


TIP: You can fine tune the sizing and placement of an object by editing the Dimensions attributes found in the object's Property List.


Now add and customize the button components:
  1. Using the technique you just learned, add the button component from the Standard Tab of the Component Palette.

  2. Adjust the button's position on the form using the centering and sizing tools from the Form Editor toolbox or by editing the button object's Dimensions attributes in the Property List.

  3. Label the button with the text "SayIt!" by editing the button object's Label attribute in the Property List.

  4. Repeat the first three steps to add the second button. Label the second button "Quiet!" When you are finished, the form should resemble the one shown in Figure 54.33.

FIG. 54.33
After adding the buttons and positioning each of the components, the VCafeTest applet should look similar to this.

Define the Interactions

At this point the VCafeTest applet will compile and would run, but clicking either the SayIt! or the Quiet! button would have no effect. If you were using Café to create this applet you would have to manually add your own Java code to the applet to make the buttons work. With Visual Café, though, you can accomplish this by using the Interaction Wizard.

Follow these steps to define the interactions between the TextField components and the two buttons:

  1. Change the mouse pointer from the Selection Tool to the Interaction Wizard Tool by clicking the Interaction Wizard Tool button on the Component Palette. The mouse pointer will change slightly to indicate that the Interaction Wizard is active.

  2. Click the SayIt! button, and holding down the left mouse button, drag the pointer to the TextField component and release the mouse button. A gray line tracing the path of the pointer, shown in Figure 54.34, will appear as you drag the mouse.

    FIG. 54.34
    Start the Interaction Wizard by connecting the components that interact.

  3. Once the left mouse button is released, the Interaction Wizard dialog shown in Figure 54.35 will open.

    FIG. 54.35
    Define the who, what, and when of component interaction using the Interaction Wizard dialog.

  4. Select the "Set the text field" action from the list labeled "Choose what you want to happen" and click the Next button to advance to the next page of the Interaction Wizard, shown in Figure 54.36.

    FIG. 54.36
    Now define the how of component interaction using the next page of the Interaction Wizard dialog box.

  5. On this page click the radiobutton marked "A constant or an expression" to open the text box below it for editing.

  6. Key in (including the quote marks) "Visual Café Test" and click the Finish button.

Clicking the Finish button generates all of the necessary Java code to support the SayIt! button's control of the TextField component and adds it to the applet's source code file. To finish building the VCafeTest applet repeat these steps, selecting the Quiet! button and the "Clear the TextField" action.

As you can see, the Interaction Wizard dialog allows for more complex interactions using different events, objects to interact with, and actions to take. Try using the Interaction Wizard with different objects and scroll through the events and actions to learn how powerful this tool can be.


TIP: You can also invoke the Interaction Wizard dialog by right-clicking an object in the Project Window or the Form Editor and selecting Add Interaction from the pop-up menu.


Test and Debug the Applet

The final, and probably most exciting, step of building the applet is testing it. And now it's time to let you in on a secret --you could have tested and debugged the applet at any point throughout the creation process! Since Visual Café generates Java source code in real-time, any changes you made through the Form Editor or the Interaction Wizard became instantly available for compiling and testing. This feature eliminates all the switching back and forth between Café and Café Studio necessary when testing or debugging the GUI using Café.

To build, compile, and execute the VCafeTest applet choose Project, Execute from the Visual Café menubar or just press Ctrl+F5. Just like Café, Visual Café will first check the project for any dependencies, compile the necessary modules, and start AppletViewer. If you've followed the directions carefully, your VCafeTest applet should look like the VCafeTest applet shown in Figure 54.37.

FIG. 54.37
The finished VCafeTest applet shown running in the AppletViewer.

Another way to test the applet is to just start the Visual Café Debugger. You start the Debugger one of three ways: by choosing Project, Run to Breakpoint; pressing F5; or by clicking the Run to Breakpoint button on the Debug Toolbox (refer to Figure 54.31).


TIP: It's always a good idea to save your work as you go along, but it's especially important to save the project before debugging. Early versions of a debugging tool like Visual Café's Debugger can be fragile creatures. If a bug in your code were serious enough to crash Visual Café you could lose any changes made since you last saved the project.


Again like Café, when the Debugger is started, Visual Café will switch to the Debug Workspace, check the project for any dependencies, compile the necessary modules, and start AppletViewer.

Using the Visual Café Debugger is much like using the Café Debugger. Set Breakpoints within the source code using the Source or Class Editor. Monitor the Call Stack, Variables, and Threads in their own windows while the Debugger runs. Like Café, Visual Café also provides controls such as Run to Breakpoint, Pause debugging, Stop debugging, Step Into, Step Over, Step Out, and Toggle Breakpoint on the Debugging toolbox.

Go ahead and experiment with each of the debug controls as well as the rest of Visual Café. Don't forget to use the Help files if you get stuck, but do keep in mind that some of the help may be incomplete or unavailable until the production version of Visual Café.