Java Code Examples for java.awt.Frame#MAXIMIZED_BOTH

The following examples show how to use java.awt.Frame#MAXIMIZED_BOTH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XWM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check if state is supported.
 * Note that a compound state is always reported as not supported.
 * Note also that MAXIMIZED_BOTH is considered not a compound state.
 * Therefore, a compound state is just ICONIFIED | anything else.
 *
 */
boolean supportsExtendedState(int state) {
    switch (state) {
      case Frame.MAXIMIZED_VERT:
      case Frame.MAXIMIZED_HORIZ:
          /*
           * WMs that talk NET/WIN protocol, but do not support
           * unidirectional maximization.
           */
          if (getWMID() == METACITY_WM) {
              /* "This is a deliberate policy decision." -hp */
              return false;
          }
          /* FALLTROUGH */
      case Frame.MAXIMIZED_BOTH:
          for (XStateProtocol proto : getProtocols(XStateProtocol.class)) {
              if (proto.supportsState(state)) {
                  return true;
              }
          }
      default:
          return false;
    }
}
 
Example 2
Source File: XWM.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check if state is supported.
 * Note that a compound state is always reported as not supported.
 * Note also that MAXIMIZED_BOTH is considered not a compound state.
 * Therefore, a compound state is just ICONIFIED | anything else.
 *
 */
boolean supportsExtendedState(int state) {
    switch (state) {
      case Frame.MAXIMIZED_VERT:
      case Frame.MAXIMIZED_HORIZ:
          /*
           * WMs that talk NET/WIN protocol, but do not support
           * unidirectional maximization.
           */
          if (getWMID() == METACITY_WM) {
              /* "This is a deliberate policy decision." -hp */
              return false;
          }
          /* FALLTROUGH */
      case Frame.MAXIMIZED_BOTH:
          for (XStateProtocol proto : getProtocols(XStateProtocol.class)) {
              if (proto.supportsState(state)) {
                  return true;
              }
          }
      default:
          return false;
    }
}
 
Example 3
Source File: XWM.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check if state is supported.
 * Note that a compound state is always reported as not supported.
 * Note also that MAXIMIZED_BOTH is considered not a compound state.
 * Therefore, a compound state is just ICONIFIED | anything else.
 *
 */
boolean supportsExtendedState(int state) {
    switch (state) {
      case Frame.MAXIMIZED_VERT:
      case Frame.MAXIMIZED_HORIZ:
          /*
           * WMs that talk NET/WIN protocol, but do not support
           * unidirectional maximization.
           */
          if (getWMID() == METACITY_WM) {
              /* "This is a deliberate policy decision." -hp */
              return false;
          }
          /* FALLTROUGH */
      case Frame.MAXIMIZED_BOTH:
          for (XStateProtocol proto : getProtocols(XStateProtocol.class)) {
              if (proto.supportsState(state)) {
                  return true;
              }
          }
      default:
          return false;
    }
}
 
Example 4
Source File: OptionsHandler.java    From JPPF with Apache License 2.0 6 votes vote down vote up
/**
 * Save the specified frame state to the preferences store.
 * @param frame the frame for which the attributes are saved.
 * @param pref the preferences node where the attributes are saved.
 */
public static void saveFrameAttributes(final Frame frame, final Preferences pref) {
  final int state = frame.getExtendedState();
  final boolean maximized = (state & Frame.MAXIMIZED_BOTH) > 0;
  if (maximized) frame.setExtendedState(Frame.NORMAL);
  final java.awt.Point p = frame.getLocation();
  pref.putInt("locationx", p.x);
  pref.putInt("locationy", p.y);
  final java.awt.Dimension d = frame.getSize();
  pref.putInt("width", d.width);
  pref.putInt("height", d.height);
  pref.putBoolean("maximized", maximized);
  try {
    pref.flush();
  } catch(final BackingStoreException e) {
    log.error(e.getMessage(), e);
  }
}
 
Example 5
Source File: XWM.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check if state is supported.
 * Note that a compound state is always reported as not supported.
 * Note also that MAXIMIZED_BOTH is considered not a compound state.
 * Therefore, a compound state is just ICONIFIED | anything else.
 *
 */
boolean supportsExtendedState(int state) {
    switch (state) {
      case Frame.MAXIMIZED_VERT:
      case Frame.MAXIMIZED_HORIZ:
          /*
           * WMs that talk NET/WIN protocol, but do not support
           * unidirectional maximization.
           */
          if (getWMID() == METACITY_WM) {
              /* "This is a deliberate policy decision." -hp */
              return false;
          }
          /* FALLTROUGH */
      case Frame.MAXIMIZED_BOTH:
          for (XStateProtocol proto : getProtocols(XStateProtocol.class)) {
              if (proto.supportsState(state)) {
                  return true;
              }
          }
      default:
          return false;
    }
}
 
Example 6
Source File: XFramePeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setVisible(boolean vis) {
    if (vis) {
        setupState(false);
    } else {
        if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            XWM.getWM().setExtendedState(this, state & ~Frame.MAXIMIZED_BOTH);
        }
    }
    super.setVisible(vis);
    if (vis && maxBounds != null) {
        setMaximizedBounds(maxBounds);
    }
}
 
Example 7
Source File: XFramePeer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void setVisible(boolean vis) {
    if (vis) {
        setupState(false);
    } else {
        if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            XWM.getWM().setExtendedState(this, state & ~Frame.MAXIMIZED_BOTH);
        }
    }
    super.setVisible(vis);
    if (vis && maxBounds != null) {
        setMaximizedBounds(maxBounds);
    }
}
 
Example 8
Source File: DefaultMainWindowManager.java    From IBC with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void windowStateChanged(WindowEvent e) {
    int state = e.getNewState();
    if (((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH)) {
        if ((Calendar.getInstance().getTimeInMillis() - lastMinimizeTime) < 2000) {
            iconizeIfRequired();
        } else {
            mainWindow.removeWindowStateListener(listener);
        }
    }
}
 
Example 9
Source File: XFramePeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void setVisible(boolean vis) {
    if (vis) {
        setupState(false);
    } else {
        if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            XWM.getWM().setExtendedState(this, state & ~Frame.MAXIMIZED_BOTH);
        }
    }
    super.setVisible(vis);
    if (vis && maxBounds != null) {
        setMaximizedBounds(maxBounds);
    }
}
 
Example 10
Source File: MaterialFrameWrapper.java    From swing-material with MIT License 5 votes vote down vote up
@Override
public void doLayout() {
    boolean max = (frame.getExtendedState() & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH;
    int hpad = MaterialShadow.OFFSET_LEFT + MaterialShadow.OFFSET_RIGHT;
    int vpad = MaterialShadow.OFFSET_TOP + MaterialShadow.OFFSET_BOTTOM;
    btnClose.setBounds(this.getWidth() - 48 - MaterialShadow.OFFSET_LEFT - 10,
        0 - MaterialShadow.OFFSET_TOP, 48 + hpad, 24 + vpad);
    if (frame.isResizable()) {
        if (max) {
            btnRestore.setBounds(this.getWidth() - 78 - MaterialShadow.OFFSET_LEFT - 10,
                0 - MaterialShadow.OFFSET_TOP, 30 + hpad, 24 + vpad);
            btnMaximize.setBounds(0,0,0,0);
            btnMaximize.setVisible(false);
            btnRestore.setVisible(true);
        } else {
            btnMaximize.setBounds(this.getWidth() - 78 - MaterialShadow.OFFSET_LEFT - 10,
                0 - MaterialShadow.OFFSET_TOP, 30 + hpad, 24 + vpad);
            btnRestore.setBounds(0,0,0,0);
            btnMaximize.setVisible(true);
            btnRestore.setVisible(false);
        }
        btnMinimize.setBounds(this.getWidth() - 108 - MaterialShadow.OFFSET_LEFT - 10,
            0 - MaterialShadow.OFFSET_TOP, 30 + hpad, 24 + vpad);
    } else {
        btnMinimize.setBounds(this.getWidth() - 78 - MaterialShadow.OFFSET_LEFT - 10,
            0 - MaterialShadow.OFFSET_TOP, 30 + hpad, 24 + vpad);
        btnMaximize.setBounds(0,0,0,0);
        btnMaximize.setVisible(false);
        btnRestore.setBounds(0,0,0,0);
        btnRestore.setVisible(false);
    }
    titleLabel.setBounds(MaterialShadow.OFFSET_LEFT, 0,
        this.getWidth() - MaterialShadow.OFFSET_TOP*2
        - (btnClose.getWidth()-MaterialShadow.OFFSET_LEFT)
        - Math.max(btnRestore.getWidth()-hpad,0)
        - Math.max(btnMaximize.getWidth()-hpad,0)
        - (btnMinimize.getWidth()-hpad), getMinimumSize().height);
}
 
Example 11
Source File: XFramePeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setVisible(boolean vis) {
    if (vis) {
        setupState(false);
    } else {
        if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            XWM.getWM().setExtendedState(this, state & ~Frame.MAXIMIZED_BOTH);
        }
    }
    super.setVisible(vis);
    if (vis && maxBounds != null) {
        setMaximizedBounds(maxBounds);
    }
}
 
Example 12
Source File: MaximizedToUnmaximized.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testFrame(boolean isUndecorated) throws Exception {
    Frame frame = new Frame();
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(100);

        frame.setUndecorated(isUndecorated);
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
        int x = bounds.x + insets.left;
        int y = bounds.y + insets.top;
        int width = bounds.width - insets.left - insets.right;
        int height = bounds.height - insets.top - insets.bottom;
        Rectangle rect = new Rectangle(x, y, width, height);
        frame.pack();
        frame.setBounds(rect);
        frame.setVisible(true);
        robot.waitForIdle();
        robot.delay(500);

        if (frame.getWidth() <= width / 2
                || frame.getHeight() <= height / 2) {
            throw new RuntimeException("Frame size is small!");
        }

        if (!isUndecorated && frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {
            throw new RuntimeException("Frame state does not equal"
                    + " MAXIMIZED_BOTH!");
        }
    } finally {
        frame.dispose();
    }
}
 
Example 13
Source File: XFramePeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void setVisible(boolean vis) {
    if (vis) {
        setupState(false);
    } else {
        if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            XWM.getWM().setExtendedState(this, state & ~Frame.MAXIMIZED_BOTH);
        }
    }
    super.setVisible(vis);
    if (vis && maxBounds != null) {
        setMaximizedBounds(maxBounds);
    }
}
 
Example 14
Source File: XFramePeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void setVisible(boolean vis) {
    if (vis) {
        setupState(false);
    } else {
        if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            XWM.getWM().setExtendedState(this, state & ~Frame.MAXIMIZED_BOTH);
        }
    }
    super.setVisible(vis);
    if (vis && maxBounds != null) {
        setMaximizedBounds(maxBounds);
    }
}
 
Example 15
Source File: XNETProtocol.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void requestState(XWindowPeer window, int state) {
    /*
     * We have to use toggle for maximization because of transitions
     * from maximization in one direction only to maximization in the
     * other direction only.
     */
    int old_net_state = getState(window);
    int max_changed = (state ^ old_net_state) & (Frame.MAXIMIZED_BOTH);

    XClientMessageEvent req = new XClientMessageEvent();
    try {
        switch(max_changed) {
          case 0:
              return;
          case Frame.MAXIMIZED_HORIZ:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
              req.set_data(2, 0);
              break;
          case Frame.MAXIMIZED_VERT:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
              req.set_data(2, 0);
              break;
          case Frame.MAXIMIZED_BOTH:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
              req.set_data(2, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
              break;
          default:
              return;
        }
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Requesting state on " + window + " for " + state);
        }
        req.set_type((int)XConstants.ClientMessage);
        req.set_window(window.getWindow());
        req.set_message_type(XA_NET_WM_STATE.getAtom());
        req.set_format(32);
        req.set_data(0, _NET_WM_STATE_TOGGLE);
        XToolkit.awtLock();
        try {
            XlibWrapper.XSendEvent(XToolkit.getDisplay(),
                    XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()),
                    false,
                    XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
                    req.pData);
        }
        finally {
            XToolkit.awtUnlock();
        }
    } finally {
        req.dispose();
    }
}
 
Example 16
Source File: UIManager.java    From sagetv with Apache License 2.0 4 votes vote down vote up
public void goodbye()
{
  if (!alive) return;
  alive = false;
  arMustGetLockNext = false;
  if (Sage.DBG) System.out.println("Killing UIMgr " + this);
  allUIs.remove(this);
  if (uiTimer != null)
  {
    uiTimer.cancel();
    if (Sage.DBG && uiTimer != null) System.out.println("Killed UI Timers");
  }
  if (vf != null)
  {
    vf.goodbye();
    if (Sage.DBG) System.out.println("Killed VideoFrame");
  }
  if (moduleGroup != null)
    Catbert.processUISpecificHook("ApplicationExiting", null, this, false);
  if (router != null) router.kill();
  if (ENABLE_STUDIO)
  {
    STVEditor study = getStudio();
    if (study != null)
    {
      study.kill();
      if (Sage.DBG) System.out.println("Killed Studio");
    }
  }
  if (rootPanel != null)
  {
    rootPanel.kill();
    if (Sage.DBG) System.out.println("Killed RootPanel");
  }
  if (isTaskbar && uiClientName.equals(Seeker.LOCAL_PROCESS_CLIENT))
    Sage.removeTaskbarIcon0(Sage.mainHwnd);
  if (currUI != null)
    currUI.terminate(false);
  if (!windowless && win != null)
  {
    if (!win.isFullScreen() && win.getExtendedState() != Frame.MAXIMIZED_BOTH)
    {
      putInt(prefs + LAST_WIN_POSX, win.getX());
      putInt(prefs + LAST_WIN_POSY, win.getY());
      putInt(prefs + LAST_WIN_WIDTH, win.getWidth());
      putInt(prefs + LAST_WIN_HEIGHT, win.getHeight());
    }
    putBoolean(prefs + LAST_WIN_FS, isFullScreen());
    win.dispose();
    if (fsWin != null)
      fsWin.dispose();
  }
  if (moduleGroup != null)
    moduleGroup.dispose();

  savePrefs();

  MetaImage.notifyOfDeadUIManager(this);

  if (Sage.DBG) System.out.println("Disposed Window");
}
 
Example 17
Source File: XNETProtocol.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void requestState(XWindowPeer window, int state) {
    /*
     * We have to use toggle for maximization because of transitions
     * from maximization in one direction only to maximization in the
     * other direction only.
     */
    int old_net_state = getState(window);
    int max_changed = (state ^ old_net_state) & (Frame.MAXIMIZED_BOTH);

    XClientMessageEvent req = new XClientMessageEvent();
    try {
        switch(max_changed) {
          case 0:
              return;
          case Frame.MAXIMIZED_HORIZ:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
              req.set_data(2, 0);
              break;
          case Frame.MAXIMIZED_VERT:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
              req.set_data(2, 0);
              break;
          case Frame.MAXIMIZED_BOTH:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
              req.set_data(2, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
              break;
          default:
              return;
        }
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Requesting state on " + window + " for " + state);
        }
        req.set_type((int)XConstants.ClientMessage);
        req.set_window(window.getWindow());
        req.set_message_type(XA_NET_WM_STATE.getAtom());
        req.set_format(32);
        req.set_data(0, _NET_WM_STATE_TOGGLE);
        XToolkit.awtLock();
        try {
            XlibWrapper.XSendEvent(XToolkit.getDisplay(),
                    XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()),
                    false,
                    XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
                    req.pData);
        }
        finally {
            XToolkit.awtUnlock();
        }
    } finally {
        req.dispose();
    }
}
 
Example 18
Source File: XNETProtocol.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void requestState(XWindowPeer window, int state) {
    /*
     * We have to use toggle for maximization because of transitions
     * from maximization in one direction only to maximization in the
     * other direction only.
     */
    int old_net_state = getState(window);
    int max_changed = (state ^ old_net_state) & (Frame.MAXIMIZED_BOTH);

    XClientMessageEvent req = new XClientMessageEvent();
    try {
        switch(max_changed) {
          case 0:
              return;
          case Frame.MAXIMIZED_HORIZ:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
              req.set_data(2, 0);
              break;
          case Frame.MAXIMIZED_VERT:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
              req.set_data(2, 0);
              break;
          case Frame.MAXIMIZED_BOTH:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
              req.set_data(2, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
              break;
          default:
              return;
        }
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Requesting state on " + window + " for " + state);
        }
        req.set_type((int)XConstants.ClientMessage);
        req.set_window(window.getWindow());
        req.set_message_type(XA_NET_WM_STATE.getAtom());
        req.set_format(32);
        req.set_data(0, _NET_WM_STATE_TOGGLE);
        XToolkit.awtLock();
        try {
            XlibWrapper.XSendEvent(XToolkit.getDisplay(),
                    XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()),
                    false,
                    XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
                    req.pData);
        }
        finally {
            XToolkit.awtUnlock();
        }
    } finally {
        req.dispose();
    }
}
 
Example 19
Source File: XNETProtocol.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void requestState(XWindowPeer window, int state) {
    /*
     * We have to use toggle for maximization because of transitions
     * from maximization in one direction only to maximization in the
     * other direction only.
     */
    int old_net_state = getState(window);
    int max_changed = (state ^ old_net_state) & (Frame.MAXIMIZED_BOTH);

    XClientMessageEvent req = new XClientMessageEvent();
    try {
        switch(max_changed) {
          case 0:
              return;
          case Frame.MAXIMIZED_HORIZ:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
              req.set_data(2, 0);
              break;
          case Frame.MAXIMIZED_VERT:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
              req.set_data(2, 0);
              break;
          case Frame.MAXIMIZED_BOTH:
              req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
              req.set_data(2, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
              break;
          default:
              return;
        }
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Requesting state on " + window + " for " + state);
        }
        req.set_type((int)XConstants.ClientMessage);
        req.set_window(window.getWindow());
        req.set_message_type(XA_NET_WM_STATE.getAtom());
        req.set_format(32);
        req.set_data(0, _NET_WM_STATE_TOGGLE);
        XToolkit.awtLock();
        try {
            XlibWrapper.XSendEvent(XToolkit.getDisplay(),
                    XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()),
                    false,
                    XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
                    req.pData);
        }
        finally {
            XToolkit.awtUnlock();
        }
    } finally {
        req.dispose();
    }
}
 
Example 20
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the state of the window. If <code>updateRegardless</code> is
 * true and the state has not changed, this will update anyway.
 *
 * @param state the state
 * @param updateRegardless the update regardless
 */
private void setState(int state, boolean updateRegardless)
{
	Window w = getWindow();

	if (w != null && getWindowDecorationStyle() == JRootPane.FRAME)
	{
		if (this.state == state && !updateRegardless)
		{
			return;
		}
		Frame frame = getFrame();

		if (frame != null)
		{
			JRootPane rootPane = getRootPane();

			if (((state & Frame.MAXIMIZED_BOTH) != 0)
					&& (rootPane.getBorder() == null || (rootPane
							.getBorder() instanceof UIResource))
					&& frame.isShowing())
			{
				rootPane.setBorder(null);
			}
			else if ((state & Frame.MAXIMIZED_BOTH) == 0)
			{
				// This is a croak, if state becomes bound, this can
				// be nuked.
				rootPaneUI.installBorder(rootPane);
			}
			if (frame.isResizable())
			{
				if ((state & Frame.MAXIMIZED_BOTH) != 0)
				{
					updateToggleButton(restoreAction, minimizeIcon, minimizeIcon_rover, minimizeIcon_pressed);
					maximizeAction.setEnabled(false);
					restoreAction.setEnabled(true);
				}
				else
				{
					updateToggleButton(maximizeAction, maximizeIcon, maximizeIcon_rover, maximizeIcon_pressed);
					maximizeAction.setEnabled(true);
					restoreAction.setEnabled(false);
				}
				if (toggleButton.getParent() == null
						|| iconifyButton.getParent() == null)
				{
					add(toggleButton);
					add(iconifyButton);
					revalidate();
					repaint();
				}
				toggleButton.setText(null);
			}
			else
			{
				maximizeAction.setEnabled(false);
				restoreAction.setEnabled(false);
				if (toggleButton.getParent() != null)
				{
					remove(toggleButton);
					revalidate();
					repaint();
				}
			}
		}
		else
		{
			// Not contained in a Frame
			maximizeAction.setEnabled(false);
			restoreAction.setEnabled(false);
			iconifyAction.setEnabled(false);
			remove(toggleButton);
			remove(iconifyButton);
			revalidate();
			repaint();
		}
		closeAction.setEnabled(true);
		this.state = state;
	}
}