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 < menu_text.length; i = i + 1) {MenuItem menu_item = new MenuItem(menu_text[i]);menu_item.setFont(menu_font);your_menu.add(menu_item);}
See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist