280 281 282 /** 283 * Sets the font to be used for this menu component to the specified 284 * font. This font is also used by all subcomponents of this menu 285 * component, unless those subcomponents specify a different font. 286 * <p> 287 * Some platforms may not support setting of all font attributes 288 * of a menu component; in such cases, calling <code>setFont</code> 289 * will have no effect on the unsupported font attributes of this 290 * menu component. Unless subcomponents of this menu component 291 * specify a different font, this font will be used by those 292 * subcomponents if supported by the underlying platform. 293 * 294 * @param f the font to be set 295 * @see #getFont 296 * @see Font#getAttributes 297 * @see java.awt.font.TextAttribute 298 */ 299 public void setFont(Font f) { 300 font = f; 301 //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font) 302 MenuComponentPeer peer = this.peer; 303 if (peer != null) { 304 peer.setFont(f); 305 } 306 } 307 308 /** 309 * Removes the menu component's peer. The peer allows us to modify the 310 * appearance of the menu component without changing the functionality of 311 * the menu component. 312 */ 313 public void removeNotify() { 314 synchronized (getTreeLock()) { 315 MenuComponentPeer p = this.peer; 316 if (p != null) { 317 Toolkit.getEventQueue().removeSourceEvents(this, true); 318 this.peer = null; 319 p.dispose(); 320 } 321 } 322 } 323 324 /** | 280 281 282 /** 283 * Sets the font to be used for this menu component to the specified 284 * font. This font is also used by all subcomponents of this menu 285 * component, unless those subcomponents specify a different font. 286 * <p> 287 * Some platforms may not support setting of all font attributes 288 * of a menu component; in such cases, calling <code>setFont</code> 289 * will have no effect on the unsupported font attributes of this 290 * menu component. Unless subcomponents of this menu component 291 * specify a different font, this font will be used by those 292 * subcomponents if supported by the underlying platform. 293 * 294 * @param f the font to be set 295 * @see #getFont 296 * @see Font#getAttributes 297 * @see java.awt.font.TextAttribute 298 */ 299 public void setFont(Font f) { 300 synchronized (getTreeLock()) { 301 font = f; 302 //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font) 303 MenuComponentPeer peer = this.peer; 304 if (peer != null) { 305 peer.setFont(f); 306 } 307 } 308 } 309 310 /** 311 * Removes the menu component's peer. The peer allows us to modify the 312 * appearance of the menu component without changing the functionality of 313 * the menu component. 314 */ 315 public void removeNotify() { 316 synchronized (getTreeLock()) { 317 MenuComponentPeer p = this.peer; 318 if (p != null) { 319 Toolkit.getEventQueue().removeSourceEvents(this, true); 320 this.peer = null; 321 p.dispose(); 322 } 323 } 324 } 325 326 /** |