Java Reference
In-Depth Information
133
Creates a menu item to change the font
face and set its action listener.
134 @param name
the name of the font face
135 @return
the menu item
136 */
137
public
JMenuItem createFaceItem(
final
String name)
138 {
139 JMenuItem item =
new
JMenuItem(name);
140
class
MenuItemListener
implements
ActionListener
141 {
142
public void
actionPerformed(ActionEvent event)
143 {
144 facename = name;
145 setSampleFont();
146 }
147 }
148 ActionListener listener =
new
MenuItemListener();
149 item.addActionListener(listener);
150
return
item;
151 }
152
153 /**
154
Creates a menu item to change the font
size
155
and set its action listener.
156 @param name
the name of the menu item
157 @param ds
the amount by which to change
the size
158 @return
the menu item
159 */
160
public
JMenuItem createSizeItem(String
name,
final int
ds)
161 {
162 JMenuItem item =
new
JMenuItem(name);
163
class
MenuItemListener
implements
ActionListener
164 {
165
public void
actionPerformed(ActionEvent event)
806
807