To give you a feel for working with the Source Editor, you will enter code in the Blink.java file to bounce the words up and down. If you haven't yet created the Blink project, you should do so now. Step-by-step instructions are in Creating a Project.
Check the Java WorkShop tool bar for the name of the current portfolio and project.
If the current portfolio is not "personal," choose Portfolio => Choose => personal. If the current project is not Blink, choose Project => Choose => Blink.
Click the Source Editor control on the WorkShop tool bar.
The WorkShop opens the Source Editor with the file Blink.java loaded.
Enter the following lines of source code. This code intentionally has errors in it. In the next lesson, you will learn how to fix the errors. The line number of the pointer is in the lower left corner of the Source Editor. You can use this field to change the location of the pointer--enter the line number to which you want to move the pointer and press Return or Enter.
After line 17
int speed;
enter:
boolean offset;
After line 25
lbl = (att == null) ? "Blink" : att;
enter:
offset = false;
After lines 53-54
g.setColor(Color.lightGray);
}
enter:
if offset
y = y * 2;
After line 57
g.drawString(word, x, y);
enter:
if (offset) {
offset = false;
y = y / 2;
else {
offset = true;
}
Click the Save control on the Source Editor tool bar. The path name of the saved file appears in the Source Editor footer.
Choose File => Close.
The WorkShop closes the Source Editor.