我有一个具有简单菜单栏的工具。它在Windows上正常工作的方式,但不适用于Mac。在Mac上,当我打开"关于"窗口,菜单消失。在Windows上它是正常的,但在Mac上应始终看到菜单。我怎样才能做到这一点?
我的代码:(请注意它正在构建中)
Menu menuBar = new Menu(newShell, SWT.BAR);
MenuItem cascadeFileMenu = new MenuItem(menuBar, SWT.CASCADE);
cascadeFileMenu.setText("&File");
Menu fileMenu = new Menu(newShell, SWT.DROP_DOWN);
cascadeFileMenu.setMenu(fileMenu);
MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
exitItem.setText("&Exit");
exitItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getShell().getDisplay().dispose();
System.exit(0);
}
});
MenuItem cascadeManageMenu = new MenuItem(menuBar, SWT.CASCADE);
cascadeManageMenu.setText("&Manage");
Menu manageMenu = new Menu(newShell, SWT.DROP_DOWN);
cascadeManageMenu.setMenu(manageMenu);
MenuItem branchItem = new MenuItem(manageMenu, SWT.PUSH);
branchItem.setText("&Branch Priority");
MenuItem libraryItem = new MenuItem(manageMenu, SWT.PUSH);
libraryItem.setText("&Library Priority");
MenuItem blankItem = new MenuItem(manageMenu, SWT.PUSH);
blankItem.setText("");
blankItem.setEnabled(false);
MenuItem historyItem = new MenuItem(manageMenu, SWT.PUSH);
historyItem.setText("&Test Run History");
MenuItem cascadeAboutMenu = new MenuItem(menuBar, SWT.CASCADE);
cascadeAboutMenu.setText("&About");
Menu aboutMenu = new Menu(newShell, SWT.DROP_DOWN);
cascadeAboutMenu.setMenu(aboutMenu);
MenuItem aboutItem = new MenuItem(aboutMenu, SWT.PUSH);
aboutItem.setText("&About Library Test Manager");
aboutItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AboutWindow aboutWindow = new AboutWindow();
aboutWindow.open();
}
});
newShell.setMenuBar(menuBar);