Java Reference
In-Depth Information
203 {
204 Font f = new Font(facename, fontstyle,
fontsize);
205 sampleField.setFont(f);
206 sampleField.repaint();
207 }
208
209 private JLabel sampleField;
210 private String facename;
211 private int fontstyle;
212 private int fontsize;
213
214 private static final int FRAME_WIDTH = 300 ;
215 private static final int FRAME_HEIGHT = 400 ;
216 }
807
808
S ELF C HECK
6. Why do JMenu objects not generate action events?
7. Why is the name parameter in the createFaceItem method
declared as final ?
18.4 Exploring the Swing Documentation
In the preceding sections, you saw the basic properties of the most common
user-interface components. We purposefully omitted many options and variations to
simplify the discussion. You can go a long way by using only the simplest properties
of these components. If you want to implement a more sophisticated effect, you can
look inside the Swing documentation. You will probably find the documentation quite
intimidating at first glance, though. The purpose of this section is to show you how
you can use the documentation to your advantage without becoming overwhelmed.
You should learn to navigate the API documentation to find out more about
user-interface components.
Recall the Color class that was introduced in Chapter 2 . Every combination of red,
green, and blue values represents a different color. It should be fun to mix your own
colors, with a slider for the red, green, and blue values (see Figure 10 ).
Search WWH ::




Custom Search