当我将我的JMenuBar
移动到Mac OS X上的屏幕菜单栏时,它会留下一些空白区域,菜单位于我的窗口中;我需要删除那个空间。我正在使用如何将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);
}
你可以张贴代码?通常情况下,布局会自动调整以使用所有房间。 – Eelke