Instructions:
Answer the following questions one at a time. After answering each question,
check your answer (by clicking on the check-mark icon if it is available)
before proceeding to the next question.
Getting Ready:
Before going any further, you should:
to an appropriate directory/folder. (In most browsers/OSs, the
easiest way to do this is by right-clicking/control-clicking on
each of the links above and then selecting Save as...
or Save link as....)
1. Starting jGRASP:
There are many different text editors. and most programmers have their
personal favorite. For this lab you will be using the text editor
in the integrated development environment (IDE) call jGRASP.
To get started:
Run jGRASP (by clicking or double-clicking on the
icon on your desktop.
"Clean up" jGRASP by clicking on File and pulling
down to Close All.
2. Text Editing Functionality for Programmers:
This part of the lab will help you gain skills with text editing
functionality that is especially useful for programmers.
Open PictureFrame.java.
What text appears in the title bar of the window that opened.
The name of the file (among other things).
For readability, all of the words return should line up
(i.e., should start in the same column). Do they?
No.
Click on View-Generate CSD.
Do all of the words return line up now?
Yes.
Click on View-Remove CSD.
Do all of the words return still line up?
Yes.
Run Checksyle. Have all of the style defects been corrected?
No! This is one of the shortcomings of jGRASP compared to some
other IDEs (though it has other advantages for beginning programmers).
So, it's a good idea to make sure your code is consistent with the
style guide from the start.
The word public is a reserved word in Java so, jGRASP
presents it in a special color.
What color?
On my machine, purple.
Go to any instance of the word public
and delete the b.
What color is it now?
On my machine, black. Hence, it must be a typo.
What changed in the title bar?
There is now an asterisk (i.e., '*').
What do you think the asterisk in the title bar indicates
(when it is there)?
The file has been changed since it was last saved.
Fix the typo you just created (i.e., change it back
to public).
Close PictureFrame.java (and only PictureFrame.java).
Open WhatAnEgo.java.
Click on View-Line Numbers
What happened?
Line numbers appeared on the left side. They are not part of the
text.
All of the text between a /* and a */
is a comment in Java (and many other programming languages).
jGRASP presents comments in a special color.
What color?
On my machine, orange.
How else can you include a comment in a Java program?
Everything on a line after a double-slashes is a comment.
You can tell because it is orange in jGRASP.
String literals are enclosed in quotes in Java
(and many other programming languages).
jGRASP presents String literals in a special color.
What color?
On my machine, green.
Turn on line numbers.
Delete the quotation mark near the end of line 21 (i.e., the second
quotation mark on the line).
What happened?
Everything after the quotation mark on that line is green, indicating that
jGRASP thinks all of those characters are part of the
String literal.
Click on Edit and pull down to Undo
(to restore the qutation mark).
Delete the quotation mark near the beginning of line 21 (i.e., the first
quotation mark on the line).
What happened?
Prof. changes to black and everything after the
quotation mark on that line is green, indicating that
everything is messed up
What happens if you hover the mouse cursor over an
open or close curly bracket?
It is highlighted and its corresponding
closing or opening curly bracket is highlighted.
Undo your last change. (At this point the file should be in
its original state. If you're not sure that it is, close the file
without saving it and re-open it.)
3. More Advanced Text Editing:
This part of the lab will help you gain some more advanced text editing
skills (that will prove beneficial throughout the semester).
You can do the same thing with Java source code.
Make WhatAnEgo.java the active window and
click on View-Generate CSD.
Now, move the cursor to the line containing main()
and click on
View-Fold-Fold.
What happened?
The lines "disappeared" and an icon with a "+" appeared in its place.
(This can be very useful when you want to work in a top down fashion,
ignoring some of the details.)
Click next to the "+" and click on
View-Fold-Unfold.
What happened?
The lines "reappeared".
Move the cursor to line 10 and
click on View-Bookmarks-
Toggle Bookmark
What happened?
A small icon appeared at the very left of the line.
What does "toggle" mean in this context?
Switch back and forth between two possible values.
Create bookmarks for lines 27, 47, and 57.
Click on View-Bookmarks-
Next Bookmark
What happened?
The cursor moved between bookmarks.
Click on View-Window Layout-2
Rows (or View-Split View-
Vertical Split depending on your version of jGRASP).
What happened?
The window split into two pieces, one above the other.
Click on View-Window
Layout-Single
(or View-Split View-
Joined) to reset the view.
4. The Keyboard and the Mouse:
This part of the lab will help you determine whethe you are more
productive using the keyboard or the mouse.
Using the mouse only, scroll to the top of the file, select the
entire file, and cut the selected text.
Undo the cut.
In the instructions/questions that follow, Ctrl denotes the
[Ctrl] key on MS Windows keyboards and the [command] on Mac keyboards.
Using the keyboard, type Ctrl-Home.
Then hold the Shift and type Ctrl-End,
Ctrl-X.
Which approach was faster.
For me, the keyboard was much faster.
Undo the cut.
Using the keyboard, type Ctrl-a,
Ctrl-X.
Which approach was faster.
There's no comparison!
Undo the cut.
Turn line numbering off by clicking on
View-Line Numbers
Turn line numbering on by typing Ctrl-L.
Which approach was faster.
For me, the keyboard was much faster.
Other than the time required to execute the command itself,
write down another advantage of using keyboard shortcuts rather than
the mouse.
It is much easier to start typing again since your hands are still in
the right place.