dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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]);
your_menu.setFont(menu_font);
for (int i = 1; i < menu_text.length; i = i + 1) {
MenuItem menu_item = new MenuItem(menu_text[i]);
menu_item.setFont(menu_font);
your_menu.add(menu_item);
}

Tom Yarker
 
Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date