Java Reference
In-Depth Information
Exercise 11.24 What does the method call frame.repaint() do, which you can see in
the makeDarker method?
Exercise 11.25 We can see a call to a method showStatus , which is clearly an internal
method call. From the name, we can guess that this method should display a status message
using the status label we created earlier. Implement this method in your version of the ima-
geviewer0-4 project. ( Hint : Look at the setText method in the JLabel class.)
Exercise 11.26 What happens if the Darker menu item is selected when no image has
been opened?
Exercise 11.27 Explain in detail how the darker method in OFImage works. ( Hint : It
contains another method call to a method also called darker . Which class does this second
method belong to? Look it up.)
Exercise 11.28 Implement the lighter filter in OFImage .
Exercise 11.29 Implement the threshold filter. To get the brightness of a pixel, you can get
its red, green, and blue values and add them up. The Color class defines static references to
suitable black, white, and gray objects.
You can find a working implementation of everything described so far in the imageviewer1-0
project. You should, however, attempt to do the exercises yourself first, before you look at the
solution.
11.5.6
Dialogs
Our last task for this version is to add a Help menu that holds a menu item labeled About
ImageViewer …When this item is selected, a dialog should pop up that displays some short
information.
Now we have to implement the showAbout method so that it displays an “About” dialog.
Exercise 11.30 Again add a menu named Help . In it, add a menu item labeled About
ImageViewer
Exercise 11.31 Add a method stub (a method with an empty body) named showAbout ,
and add an action listener to the About ImageViewer . . .menu item that calls this method.
One of the main characteristics of a dialog is whether or not it is modal . A modal dialog blocks
all interaction with other parts of the application until the dialog has been closed. It forces the
user to deal with the dialog first. Non-modal dialogs allow interaction in other frames while the
dialogs are visible.
 
Search WWH ::




Custom Search