1 13 14 15 package org.netbeans.core.windows.actions; 16 17 18 import javax.swing.JCheckBoxMenuItem ; 19 import javax.swing.JComponent ; 20 21 import org.netbeans.core.windows.view.ui.MainWindow; 22 import org.openide.awt.DynamicMenuContent; 23 import org.openide.util.HelpCtx; 24 import org.openide.util.NbBundle; 25 import org.openide.util.actions.SystemAction; 26 import org.openide.awt.Mnemonics; 27 import org.openide.windows.WindowManager; 28 29 30 33 public class ToggleFullScreenAction extends SystemAction implements DynamicMenuContent { 34 35 private JCheckBoxMenuItem [] menuItems; 36 37 public JComponent [] getMenuPresenters() { 38 createItems(); 39 updateState(); 40 return menuItems; 41 } 42 43 public JComponent [] synchMenuPresenters(JComponent [] items) { 44 updateState(); 45 return items; 46 } 47 48 private void updateState() { 49 MainWindow frame = (MainWindow)WindowManager.getDefault().getMainWindow(); 50 menuItems[0].setSelected(frame.isFullScreenMode()); 51 } 52 53 private void createItems() { 54 if (menuItems == null) { 55 menuItems = new JCheckBoxMenuItem [1]; 56 menuItems[0] = new JCheckBoxMenuItem (this); 57 menuItems[0].setIcon(null); 58 Mnemonics.setLocalizedText(menuItems[0], NbBundle.getMessage(ToggleFullScreenAction.class, "CTL_ToggleFullScreenAction")); 59 } 60 } 61 62 63 public void actionPerformed(java.awt.event.ActionEvent ev) { 64 MainWindow frame = (MainWindow)WindowManager.getDefault().getMainWindow(); 65 frame.setFullScreenMode( !frame.isFullScreenMode() ); 66 } 67 68 public String getName() { 69 return NbBundle.getMessage(ToggleFullScreenAction.class, "CTL_ToggleFullScreenAction"); 70 } 71 72 public HelpCtx getHelpCtx() { 73 return new HelpCtx(ToggleFullScreenAction.class); 74 } 75 76 public boolean isEnabled() { 77 return WindowManager.getDefault().getMainWindow() instanceof MainWindow; 78 } 79 } 80 81 | Popular Tags |