JMU JMU - Department of Computer Science
Help Tools
Lab: Skills - Using the jGRASP Editor


http://imgs.xkcd.com/comics/real_programmers.png
(Courtesy of xkcd)

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:

  1. Download the following files:
    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:
  1. Run jGRASP (by clicking or double-clicking on the jgrasp.gif icon on your desktop.
  2. "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.
  1. Open PictureFrame.java.
  2. What text appears in the title bar of the window that opened.


    The name of the file (among other things).
    Expand
  3. For readability, all of the words return should line up (i.e., should start in the same column). Do they?


    No.
    Expand
  4. Click on View-Generate CSD.
  5. Do all of the words return line up now?


    Yes.
    Expand
  6. Click on View-Remove CSD.
  7. Do all of the words return still line up?


    Yes.
    Expand
  8. 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.
    Expand
  9. The word public is a reserved word in Java so, jGRASP presents it in a special color. What color?


    On my machine, purple.
    Expand
  10. Go to any instance of the word public and delete the b.
  11. What color is it now?


    On my machine, black. Hence, it must be a typo.
    Expand
  12. What changed in the title bar?


    There is now an asterisk (i.e., '*').
    Expand
  13. 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.
    Expand
  14. Fix the typo you just created (i.e., change it back to public).
  15. Close PictureFrame.java (and only PictureFrame.java).
  16. Open WhatAnEgo.java.
  17. Click on View-Line Numbers
  18. What happened?


    Line numbers appeared on the left side. They are not part of the text.
    Expand
  19. 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.
    Expand
  20. 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.
    Expand
  21. 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.
    Expand
  22. Turn on line numbers.
  23. Delete the quotation mark near the end of line 21 (i.e., the second quotation mark on the line).
  24. 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.
    Expand
  25. Click on Edit and pull down to Undo (to restore the qutation mark).
  26. Delete the quotation mark near the beginning of line 21 (i.e., the first quotation mark on the line).
  27. What happened?


    Prof. changes to black and everything after the quotation mark on that line is green, indicating that everything is messed up
    Expand
  28. 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.
    Expand
  29. 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).
  1. 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.
  2. 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.)
    Expand
  3. Click next to the "+" and click on View-Fold-Unfold.
  4. What happened?


    The lines "reappeared".
    Expand
  5. Move the cursor to line 10 and click on View-Bookmarks- Toggle Bookmark
  6. What happened?


    A small icon appeared at the very left of the line.
    Expand
  7. What does "toggle" mean in this context?


    Switch back and forth between two possible values.
    Expand
  8. Create bookmarks for lines 27, 47, and 57.
  9. Click on View-Bookmarks- Next Bookmark
  10. What happened?


    The cursor moved between bookmarks.
    Expand
  11. Click on View-Window Layout-2 Rows (or View-Split View- Vertical Split depending on your version of jGRASP).
  12. What happened?


    The window split into two pieces, one above the other.
    Expand
  13. 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.
  1. Using the mouse only, scroll to the top of the file, select the entire file, and cut the selected text.
  2. Undo the cut.
  3. In the instructions/questions that follow, Ctrl denotes the [Ctrl] key on MS Windows keyboards and the [command] on Mac keyboards.
  4. Using the keyboard, type Ctrl-Home. Then hold the Shift and type Ctrl-End, Ctrl-X.
  5. Which approach was faster.


    For me, the keyboard was much faster.
    Expand
  6. Undo the cut.
  7. Using the keyboard, type Ctrl-a, Ctrl-X.
  8. Which approach was faster.


    There's no comparison!
    Expand
  9. Undo the cut.
  10. Turn line numbering off by clicking on View-Line Numbers
  11. Turn line numbering on by typing Ctrl-L.
  12. Which approach was faster.


    For me, the keyboard was much faster.
    Expand
  13. 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.
    Expand
  14. Write down three other useful keyboard shortcuts.


Copyright 2020