KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > actions > ToggleFullScreenAction


1 /*
2  * Sun Public License Notice
3  *
4  * The contents of this file are subject to the Sun Public License
5  * Version 1.0 (the "License"). You may not use this file except in
6  * compliance with the License. A copy of the License is available at
7  * http://www.sun.com/
8  *
9  * The Original Code is NetBeans. The Initial Developer of the Original
10  * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
11  * Microsystems, Inc. All Rights Reserved.
12  */

13
14
15 package org.netbeans.core.windows.actions;
16
17
18 import javax.swing.JCheckBoxMenuItem JavaDoc;
19 import javax.swing.JComponent JavaDoc;
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 /**
31  * @author S. Aubrecht
32  */

33 public class ToggleFullScreenAction extends SystemAction implements DynamicMenuContent {
34
35     private JCheckBoxMenuItem JavaDoc [] menuItems;
36     
37     public JComponent JavaDoc[] getMenuPresenters() {
38         createItems();
39         updateState();
40         return menuItems;
41     }
42
43     public JComponent JavaDoc[] synchMenuPresenters(JComponent JavaDoc[] 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 JavaDoc[1];
56             menuItems[0] = new JCheckBoxMenuItem JavaDoc(this);
57             menuItems[0].setIcon(null);
58             Mnemonics.setLocalizedText(menuItems[0], NbBundle.getMessage(ToggleFullScreenAction.class, "CTL_ToggleFullScreenAction"));
59         }
60     }
61
62     /** Perform the action. Sets/unsets maximzed mode. */
63     public void actionPerformed(java.awt.event.ActionEvent JavaDoc ev) {
64         MainWindow frame = (MainWindow)WindowManager.getDefault().getMainWindow();
65         frame.setFullScreenMode( !frame.isFullScreenMode() );
66     }
67
68     public String JavaDoc 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