Java Reference
In-Depth Information
166 {
167 fontsize = fontsize + ds;
168 setSampleFont();
169 }
170 }
171 ActionListener listener = new
MenuItemListener();
172 item.addActionListener(listener);
173 return item;
174 }
175
176 /**
177 Creates a menu item to change the font
style
178 and set its action listener.
179 @param name the name of the menu item
180 @param style the new font style
181 @return the menu item
182 */
183 public JMenuItem createStyleItem(String
name, final int style)
184 {
185 JMenuItem item = new JMenuItem(name);
186 class MenuItemListener implements
ActionListener
187 {
188 public void
actionPerformed(ActionEvent event)
189 {
190 fontstyle = style;
191 setSampleFont();
192 }
193 }
194 ActionListener listener = new
MenuItemListener();
195 item.addActionListener(listener);
196 return item;
197 }
198
199 /**
200 Sets the font of the text sample.
201 */
202 public void setSampleFont()
Search WWH ::




Custom Search