如何將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);}
添加回答
舉報
0/150
提交
取消
