Professional Documents
Culture Documents
JCreator is an integrated development environment (IDE). An IDE vides a workspace that allows for editing, compiling, and running of source code. The JCreator IDE has a graphical user interface, which makes it easy to learn and use.
The JCreator IDE can be used to create Java applets, console applications, and Swing applications. JCreator maintains each applet and application as a project. Projects are created in a workspace environment, which consists of several windows:
window
code editor
The File View window displays the folders and files associated with the project workspace. The Package View window displays the classes associated with the project workspace. The code editor window is used to type and edit Java and HTML code. The Output window displays Java program output, build errors, a task list, and debug output.
To start JCreator, double-click on the Desktop Icon or select Start - All Programs - JCreator JCreator. When JCreator is started, if an existing workspace is open, it is important to select File Close Workspace before creating a new project because a workspace can contain more than one project.
Java applets can be viewed in a website. Applets are created in Unit 4. JCreator contains a Basic Java Applet template that can be modified to easily create Java Applets. JCreator also contains an Applet Viewer that is used to view applets as they will appear on a web page. If the Basic Java Applet template is not modified, it will appear similar to the window below when it is compiled and run in JCreator:
JCreator Basic Java Applet template displayed in the JCreator Applet Viewer To create a Java Applet, select File New - Project and then select Basic Java Applet from the Project Wizard dialog box. Select Next to display the second Project Wizard dialog box. In the Name box, type a descriptive applet name, verify that the project paths are correct in the Location, Source
Path, and Output Path boxes. If the project paths are not correct, click beside the corresponding box and select the appropriate path from the Select Directory dialog box. Select Finish to create the project workspace, folders, and files. A Basic Java application template automatically generates a .java file and an .htm file. To create an applet, first modify and compile the .java file. Select File Execute Project to view the applet in the JCreator Applet Viewer. Next, modify the .htm file so that the applet is appropriately placed in the HTML document. The applet can then be viewed in a web browser.
Review: Welcome
START 'CREATOR CREATE A NEW PROJECT
a. Select File - New Project. The Project Wizard dialog box is displayed. b. In the Project Wizard dialog box, select Basic Java Applet:
Select Next. The second Project Wizard dialog box is displayed. In the Name box, type Welcome:
e. Verify that the project paths are correct in the Location, Source Path, and Output Path boxes. If the project paths are not correct, click beside the corresponding box and select the appropriate path from the Select Directory dialog box. f. Select Create new workspace, if it is not already selected. g. Select Finish. The File View window displays the folders and files associated with the Basic Java Applet template. h. Click it to expand the two project folders:
i. Double-click window.
Welcome.java
b. In line 19, change "Welcome to Java!!" to This is my first Java Applet! ! and change "50, 60" to 100, 100:
NOTES : Project files for a console application will include the Java source code (.java), the Java bytecode (.class), the workspace description file(.jcw) and the project description file (.jcp)
A PROJECT MUST HAVE THE SAME NAME AS THEF FILE THAT CONTAINS THE CONTROLLING CLASS
CREATING A CONSOLE APPLICATION
A console application displays output in a DOS window. Console applications are created in Chapters 3 through 10 and Chapters 12 through 14. To create a console application, select File - New - Project and then select Empty Project from the Project Wizard dialog box. Select Next to display the second Project Wizard dialog box. In the Name box, type a descriptive application name, verify that the project paths are correct in the Location, Source Path, and Output Path boxes. If the project paths are not correct, click beside the corresponding box and select the appropriate path from the Select Directory dialog box. Select Finish to create the project workspace and folder. A new Java file is then created by selecting File New -+ File or clicking the New File button (j _II) on the toolbar, which displays the File Wizard dialog box. In the Name box, type the same name as the application name and then select Finish. After typing a program, select File y Save All to save the program file(s) and select File y Save Workspace to associate the file with the workspace. If the workspace is not saved, the added program file will not appear in the File View window when the project workspace is opened even though the program file is in the project directory. When finished working in JCreator, select File y Exit to remove the JCreator IDE from the Desktop
c. Select Next. The second Project Wizard dialog box is displayed. d. In the Name box, type Message:
e. Verify that the project paths are correct in the Location, Source Path, and Output Path boxes. If the project paths are not correct, click Q beside the corresponding box and select the appropriate path from the Select Directory dialog box.
f.
g. Select Finish. The Message workspace file and project folder are displayed in the File View window.
Note that your screen may be white and black text. Click in to change the output window options. c. Press any key to remove the output window.
The JCreator compiler will display any errors in the Task List window when the program is compiled:
The Task List displays a description of the error and the error location
Double-click the error message to display a red arrow next to the line of code containing the error. To remove an error message, correct the error and then compile the project.
To print the source code, click the code editor window and then select File - Print. To print the contents of the output window, select SI - Edit Select All and then select SI Edit y Copy. The contents can then be pasted into a word processor and printed.
You will open the Message workspace and print the code.
PRINT MESSAGE
a. In the File View window, double-click Message.java. b. Click the code editor window. c. Select File - Print.
JCreator has several help features that can be accessed in the Help menu. The Help Contents and JDK Help commands access a database of help topics that can be searched and the JCreator on the Web command provides links to technical support information on the JCreator website.