Java Reference
In-Depth Information
132 JPanel panel =
new
JPanel();
133 panel.add(smallButton);
134 panel.add(mediumButton);
135 panel.add(largeButton);
136 panel.setBorder(
137
new
TitledBorder(
new
EtchedBorder(),
ÐSizeÑ
));
138
139
return
panel;
140 }
141
142 /**
143
Gets user choice for font name, style,
and size
144
and sets the font of the text sample.
145 */
146
public void
setSampleFont()
147 {
148 //
Get font name
149 String facename
150 = (String)
facenameCombo.getSelectedItem();
151
152 //
Get font style
153
154
int
style =
0
;
155
if
(italicCheckBox.isSelected())
156 style = style + Font.ITALIC;
157
if
(boldCheckBox.isSelected())
158 style = style + Font.BOLD;
159
160 //
Get font size
161
162
int
size =
0
;
163
164
final int
SMALL_SIZE =
24
;
165
final int
MEDIUM_SIZE =
36
;
166
final int
LARGE_SIZE =
48
;
167
168
if
(smallButton.isSelected())
169 size = SMALL_SIZE;
170
else if
(mediumButton.isSelected())
171 size = MEDIUM_SIZE;
797
798