devxlogo

Controlling the Menu Font

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 

devx-admin

Share the Post: