Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: All
May 15, 1998



Application Security Testing: An Integral Part of DevOps

Controlling the Menu Font

On some platforms, the default font used by Java for menu text is unfortunately not the user-selected, system-wide menu font. With some VMs it can be undesirably small. You can control the font in a platform-independent manner, but surprisingly it is necessary to set the font of each item in the menu, and not just the font of the menu object.

import java.awt.*;
String[] menu_text = { "Your Menu Title"
                     , "Your 1st Choice"
                     , "Your 2nd Choice"
                     , "Your 3rd Choice" };

Font menu_font = new Font("Dialog", Font.PLAIN, 14);
Menu your_menu = new Menu(menu_text[0]);
for (int i = 1; i < menu_text.length; i = i + 1) {
MenuItem menu_item = new MenuItem(menu_text[i]);

Tom Yarker
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date