2
* Sun Public License Notice
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
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.
13
If you wish your version of this file to be governed by only the CDDL
14
or only the GPL Version 2, indicate your decision by adding
15
"[Contributor] elects to include this software in this distribution
16
under the [CDDL or GPL Version 2] license." If you do not indicate a
17
single choice of license, a recipient has the option to distribute
18
your version of this file under either the CDDL, the GPL Version 2 or
19
to extend the choice of license to its licensees as provided above.
20
However, if you add GPL Version 2 code and therefore, elected the GPL
21
Version 2 license, then the option applies only if the new code is
22
made subject to such option by the copyright holder.
26
package org.netbeans.core.windows.actions;
29
import java.beans.PropertyChangeEvent;
30
import java.beans.PropertyChangeListener;
31
import javax.swing.Action;
32
import javax.swing.JCheckBoxMenuItem;
33
import javax.swing.JComponent;
35
import org.netbeans.core.windows.view.ui.MainWindow;
36
import org.openide.awt.DynamicMenuContent;
37
import org.openide.util.HelpCtx;
38
import org.openide.util.NbBundle;
39
import org.openide.util.actions.SystemAction;
40
import org.openide.awt.Mnemonics;
41
import org.openide.windows.WindowManager;
47
public class ToggleFullScreenAction extends SystemAction implements DynamicMenuContent {
49
private JCheckBoxMenuItem [] menuItems;
51
public ToggleFullScreenAction() {
52
addPropertyChangeListener( new PropertyChangeListener() {
54
public void propertyChange(PropertyChangeEvent evt) {
55
if( Action.ACCELERATOR_KEY.equals(evt.getPropertyName()) ) {
56
//119127 - make sure shortcut gets updated in the menu
64
public JComponent[] getMenuPresenters() {
70
public JComponent[] synchMenuPresenters(JComponent[] items) {
75
private void updateState() {
76
MainWindow frame = (MainWindow)WindowManager.getDefault().getMainWindow();
77
menuItems[0].setSelected(frame.isFullScreenMode());
80
private void createItems() {
81
if (menuItems == null) {
82
menuItems = new JCheckBoxMenuItem[1];
83
menuItems[0] = new JCheckBoxMenuItem(this);
84
menuItems[0].setIcon(null);
85
Mnemonics.setLocalizedText(menuItems[0], NbBundle.getMessage(ToggleFullScreenAction.class, "CTL_ToggleFullScreenAction"));
89
/** Perform the action. Sets/unsets maximzed mode. */
90
public void actionPerformed(java.awt.event.ActionEvent ev) {
91
MainWindow frame = (MainWindow)WindowManager.getDefault().getMainWindow();
92
frame.setFullScreenMode( !frame.isFullScreenMode() );
95
public String getName() {
96
return NbBundle.getMessage(ToggleFullScreenAction.class, "CTL_ToggleFullScreenAction");
99
public HelpCtx getHelpCtx() {
100
return new HelpCtx(ToggleFullScreenAction.class);
104
public boolean isEnabled() {
105
return WindowManager.getDefault().getMainWindow() instanceof MainWindow;