private void computeContents() { ButtonGroup bgroup = new ButtonGroup(); bgroup.add(nullItem); removeAll(); add(minimize); add(zoom); add(close); if (!persistentItems.isEmpty()) { addSeparator(); for (JRadioButtonMenuItem item : persistentItems) { bgroup.add(item); add(item); } } if (!transientItems.isEmpty()) { addSeparator(); for (JRadioButtonMenuItem item : transientItems) { bgroup.add(item); add(item); } } WindowMenuItemManager currentManager = WindowMenuManager.getCurrentManager(); if (currentManager != null) { JRadioButtonMenuItem item = currentManager.getMenuItem(this); if (item != null) { item.setSelected(true); } } }
public WindowMenu(JFrame owner) { this.owner = owner; WindowMenuManager.addMenu(this); int menuMask = getToolkit().getMenuShortcutKeyMask(); minimize.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, menuMask)); close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, menuMask)); if (owner == null) { minimize.setEnabled(false); zoom.setEnabled(false); close.setEnabled(false); } else { minimize.addActionListener(myListener); zoom.addActionListener(myListener); close.addActionListener(myListener); } computeEnabled(); computeContents(); LocaleManager.addLocaleListener(myListener); myListener.localeChanged(); }
public static void showPreferences() { JFrame frame = MENU_MANAGER.getJFrame(true); frame.setVisible(true); }
void computeEnabled() { WindowMenuItemManager currentManager = WindowMenuManager.getCurrentManager(); minimize.setEnabled(currentManager != null); zoom.setEnabled(currentManager != null); close.setEnabled(currentManager != null); }