Java Reference
In-Depth Information
wide lines. See java.awt.BasicStroke to learn how to draw with wide
lines.
10-5.
One shortcoming of the FontChooser class is that when you call setSe-
lectedFont() , the ItemChooser components are not updated to match the
current font. Modify FontChooser so that it does update these selections.
You'll probably want to modify ItemChooser so that, in addition to its set-
SelectedIndex() method, it also has setSelectedLabel() and setSelect-
edValue() methods that specify the selected item by label or by value.
10-6. Modify the ShowComponent program to add a Show Proper ties... com-
mand to the menu. When the user selects this menu item, the program
should use the PropertyTable component (in a separate window) to dis-
play the list of properties defined by the currently displayed component.
To enable this, you need to keep track of the displayed components, and
you have to query the JTabbedPane to find which component is currently
displayed.
Once you can display the table of properties correctly, add a menu item to
the property display window. This item, when selected, should find the
selected row of the table (use getSelectedRow() ), and then allow the user
to set that property. Use one of the static methods of JOptionPane to dis-
play a dialog that allows the user to enter a property value (as a string),
then parse that value and set the specified property.
10-7. Modify ShowComponent again so that it has a Containment Hierarchy...
menu item. When the user selects this item, the program should use a
ComponentTree component (in a separate window) to display the contain-
ment hierarchy of the currently displayed component.
10-8.
A common feature of web browsers is a Go menu that lists the last 10 or
15 URLs that have been visited and provides a quick way to revisit those
sites. Add this feature to the WebBrowser class. Note that WebBrowser
already tracks its browsing history. You need to add a Go menu to the
JMenuBar that is read from the GUIResourceBundle . The contents of the Go
menu depends on the current browsing history. One technique is to
change the contents of the menu each time the browser visits a new page.
Alternately, you can use a MenuListener object to receive notification just
before the menu is popped up, and then, from the menuSelected()
method of the listener, add the appropriate items to the menu.
10-9. The GUIResourceBundle class and the ResourceParser extension interface
provide a powerful mechanism for describing a GUI in a properties file.
Implement more ResourceParser classes to support other resource types.
In particular, write parsers for the ImageIcon and KeyStroke classes; sup-
port for these two types is required to fully support the ActionParser
class.
10-10. Modify the ShowComponent class to use the ThemeManager class (with an
appropriate properties file) and the Themes menu it can create. Ideally,
you should make the Themes menu a submenu of the Look and Feel
menu the program already displays.
Search WWH ::




Custom Search