ADDITIONAL SYSTEM INFORMATION :
Windows 11
OpenJdk 20.0.1
Display Resolution: 3840x2160
Display Scaling: 250% (Recommended)
A DESCRIPTION OF THE PROBLEM :
When adding a java.awt.MenuBar to a JFrame, the height of the MenuItems does not scale with the rest of the window. As the text of the MenuItems retains the normal size, the MenuItems overlap.
This behaviour is present in many popular libraries and applications. One example is ImageJ/Fiji, which has hundreds of different MenuItems as main user input. Bugs like this give an application an unprofessional appearance.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame("Some Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("File");
menuBar.add(menu);
MenuItem menuItem1 = new MenuItem("Open");
MenuItem menuItem2 = new MenuItem("Save as");
menu.add(menuItem1);
menu.add(menuItem2);
frame.setMenuBar(menuBar);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
FREQUENCY : always