Java Reference
In-Depth Information
9 . Show how to create a text field that has 32 columns.
10 . Can a JTextField have its action command set? If so, how?
11 . What Swing component creates a check box? What event is generated when a check
box is selected or deselected?
12 .
JList displays a list of items from which the user can select. True or False?
13 . What event is generated when the user selects or deselects an item in a JList ?
14 . What method sets the selection mode of a JList ? What method obtains the index of
the first selected item?
15 . To create a Swing-based applet, what class must you inherit?
16 . Usually, Swing-based applets use invokeAndWait( ) to create the initial GUI. True or
False?
17 . Add a check box to the file comparer developed in Try This 15-1 that has the follow-
ing text: Show position of mismatch. When this box is checked, have the program
display the location of the first point in the files at which a mismatch occurs.
18 . Change the ListDemo program so that it allows multiple items in the list to be selec-
ted.
19. Bonus challenge: Convert the Help class developed in Try This 4-1 into a Swing-
based GUI program. Display the keywords ( for , while , switch , and so on) in a JList .
When the user selects one, display the keyword's syntax. To display multiple lines of
text within a label, you can use HTML. When doing so, you must begin the text with
the sequence <html> . When this is done, the text is automatically formatted as de-
scribed by the markup. In addition to other benefits, using HTML enables you to cre-
ate labels that span two or more lines. For example, this creates a label that displays
two lines of text, with the string "Top" over the string "Bottom".
No answer is shown for this exercise. You have reached the point where you are
ready to apply your Java skills on your own!
Search WWH ::




Custom Search