Java Reference
In-Depth Information
Code completion
Often, we are reasonably familiar with a library class that we are using but we still cannot re-
member the exact names of all methods or the exact parameters. For this situation, development
environments commonly offer some help: code completion.
Code completion is a function that is available in BlueJ's editor when the cursor is behind the
dot of a method call. In this situation, typing CTRL-space will bring up a pop-up listing all
methods in the interface of the object we are using in the call (Figure 5.7).
Figure 5.7
Code completion
When the code completion pop-up is displayed, we can type the beginning of the method name
to narrow down the method list. Hitting Return enters the selected method call into our source
code. Code completion can also be used without a preceding object to call local methods.
Using code completion should not be a replacement for reading the documentation of a class,
because it does not include all information (such as the introductory class comment). But once
we are reasonably familiar with a class in general, code completion is a great aid for more eas-
ily recalling details of a method and entering the call into our source.
Exercise 5.61 Add a method to your DrawDemo class that produces a picture on the can-
vas directly (without using a pen object). The picture can show anything you like, but should at
least include some shapes, different colors, and text. Use code completion in the process of
entering your code.
Search WWH ::

Custom Search