| CSCI A201/A597Lab Notes 5 Spring 2000 |
BreezyGUI that was
part of the textbook and CD that we used in A202 that semester. This is not too far
away from using the element package, so I don't think it will present a
problem to adapt it too one of this year's examples. I will try to update the screens
later in the semester, if I can, and in the meanwhile please let us know if you have
any trouble running Symantec. Step 1: Create a new Cafe project
a: which should be a floppy like the one you received in the lab
a couple of weeks ago (containing the element and structure
packages and directories).
Project001.prj as the name of the project. It's actually fine
to give it any other name and you should be using a name that is appropriate for the project you're working with. Note also how the selected drive lists
the name of your diskette (You see that the tutorial is dated because at the time we named the floppies that we
distributed by the name of the course and the semester.)
element and structure folders should be listed just like the
breezygui directory is listed in the picture.
BreezyGUI was the package that came
with the textbook that semester. You should be creating your project at the same
level as the two packages ditributed
or your program won't be able to use them, as explained in class.
Next button at the bottom of the window (next to "Finish"). The Project
Express window will display
"Set project type" settings. You need to specify if your project will be an applet or an application.
Application for the target type, as follows:
Project001.prj project. Of course your project is currently empty.
So far you haven't done anything Java yet. Various IDEs may have different interfaces and/or settings or definitions. Use the documentation that comes with the one you're having. JDK, which is available for free from Sun, does not contain anything but Java. But you have to use your own editor and compile from the command line prompt (which we will always find as a useful piece of knowledge).
We create the source code for our program now. We write Java code now. What follows is Java. What we have done so far could have been Java Workshop, Visual Age for Java, Microsoft J++, JBuilder etc.
Feb03 programs instead. Replace the two
import statements with the one that imports the element package).
Here's the code for the second Feb03 program for your convenience.
import element.*;
public class Feb03Commands {
public static void main(String[] args) {
ConsoleWindow c = new ConsoleWindow();
DrawingWindow d = new DrawingWindow();
c.out.println("Welcome to the Line Drawing program!\n");
c.out.println("At the prompt type 'line', then an x and a y and\n" +
"then press Enter. The initial point is (100,100)");
d.moveTo(100, 100);
c.out.println("To stop the program please type: quit.\n");
c.out.print("Line> "); c.out.flush();
while (true) {
String user = c.input.readString();
if (user.equals("quit")) {
System.exit(0);
}
int dX = c.input.readInt();
int dY = c.input.readInt();
d.line(dX, dY);
c.out.print("Line> "); c.out.flush();
}
}
}
Note that you can
maximize the Source editing window for your convenience. The editor is good in Cafe and I am sure
you will like it. But you do have to come up with the Java code, it won't write it for you. The
editor will however help you locate compilation errors quickly, ask your lab coordinator for more
details.
Once again, the screens that follow present the a source code for a program written for A202
of the spring 1999 semester so please don't get too confused about that. Your screens will have
the source code that you type, for example the Feb03Commands class.
Notepad. Again, this is not Java, it's just an
environment for developing programs which knows a bit of Java syntax though).
CircleArea.java, rather call it) Feb03Commands as
the class. Note that BreezyGUI's directory is in the same directory with the project
in the screen. That means that your element and structure directories should
be at the same level as your .java file. Now press the OK button to finish saving the file.
CircleArea.java filename
(Feb03Commands in your case) appears in the project window on the right.
(See the screen presented at the next step, Building the Project). This indicates
that the file is now part of the project.
Building the project essentially means running javac and java on the
source code files in your project. An IDE hides this away from you, and sometimes for the worse.
But fortunately we know how to compile and run from the command line so this won't be a problem.
When we will need it (in some cases when we have a certain type of run-time errors we need to
be able to use the command line) we will know how to do it.
Steps 4 and 5 can be performed together using the runner icon
that is located at the top of the window. If there are no errors then the system proceeds
to invoking java on the file that contains the main class. If there are errors
you ill be notified and you can quickly jump to that place in the source code by clicking
on the error messages in the Output window.
If you decide to compile and run in two separate steps here's how you run the program.
Notice however that the DOS window will open up any time you run an application.
When you're done exit Symantec Cafe.