Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Tools of the trade, Part 1

Discover the world of Java tools by exploring JCreator

  • Print
  • Feedback

Page 4 of 6

Use JCreator's editor to enter Listing 1's source code. The editor has the usual basic features: insert/delete/update text, clipboard support for copy/cut/paste, unlimited undo, and so on. In addition, the editor has some advanced features that hasten source code entry and locate source code items:

  • Class wizard: JCreator's editor works with a class wizard to speed up the entry of class, field variable, and method source code. Access the class wizard via the ClassWizard dialog box by clicking the right mouse button on the Imports line in the ClassView window and selecting New Class from the pop-up menu.

    Note
    The Imports line appears in the ClassView window if the source file contains at least one import directive. If no import directives exist, that line does not appear; but you can still access the class wizard by selecting New Class from the Project menu.


    The ClassWizard dialog box lets you enter the class name, provide various class properties (such as whether the class is public and has a superclass other than java.lang.Object), and specify the class's field variables and methods. Click OK and the class wizard generates a source file with appropriate source code.

    Because the Lines project consists of a single Lines.java source file that contains a single Lines class, this project does not require the class wizard. But keep the class wizard in mind for your own projects.

  • Code templates: JCreator's editor lets you enter an abbreviation for a code sequence. Then, after you press the Tab key, the editor automatically expands that abbreviation into the code sequence the abbreviation represents. The combination of a code sequence and its abbreviation is a code template. For example, type comment and press Tab. The editor replaces comment with /****/ spread out over three lines.

    Tip
    To display a pop-up list of all available abbreviations, either select Code Templates from the Edit menu or press the Ctrl, Shift, and N keys simultaneously.
  • Line numbers: By default, JCreator's editor displays line numbers as you enter lines of source code. Those numbers appear in the selection margin (a vertical margin to the left of source code lines that facilitates line selection), which Figure 2 displays.
  • Syntax highlighting: As Figure 2 shows, JCreator's editor highlights various source code elements, such as method names, literals, and keywords, in different colors. That color-coding lets you discover certain coding mistakes prior to compilation. For example, if most of the source file appears in green (the default comment color), chances are, you forgot to close a comment.


Once you finish entering Listing 1's source code, use the File menu's Save or Save As menu items to save that source code to Lines.java.

Compile and run the applet project

After saving the source code to Lines.java, compile the Lines project by selecting Compile Project from the Build menu (or press the F7 function key). JCreator launches an external compiler program to compile the source code. If you chose to not have JCreator capture that program's output to the Build tab of the bottommost workspace window, build messages will appear in an external command window. However, you can choose to have JCreator capture the compiler's output to the Build tab (and avoid the external window) by completing the following steps:

  • Print
  • Feedback

Resources