当我将 JMenuBar
移动到 Mac OS X 的屏幕菜单栏上时,它会留下一些空白空间,这些空白处原本是我的窗口菜单; 我需要移除那个空间。 我正在使用
System.setProperty("apple.laf.useScreenMenuBar", "true")
要将我的
JMenuBar
移动到屏幕菜单栏。我的朋友使用Mac时报告说,如果我没有设置该属性,菜单所在的位置会留下一些丑陋的垂直空间。解决这个问题的最佳方法是什么?编辑:以下是我的源代码示例:
public static void main(String[] args) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Name");
JFrame frame = new JFrame("Gabby");
final DesktopMain dm = new DesktopMain();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(dm);
frame.setSize(160, 144);
frame.setLocationRelativeTo(null);
frame.setIgnoreRepaint(true);
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
menuBar.add(fileMenu);
// Populating the menu bar code goes here
frame.setJMenuBar(menuBar);
frame.setVisible(true);
}