Java Code Examples for java.awt.peer.FramePeer#setMenuBar()

The following examples show how to use java.awt.peer.FramePeer#setMenuBar() . 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: Frame.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes the specified menu bar from this frame.
 * @param    m   the menu component to remove.
 *           If <code>m</code> is <code>null</code>, then
 *           no action is taken
 */
public void remove(MenuComponent m) {
    if (m == null) {
        return;
    }
    synchronized (getTreeLock()) {
        if (m == menuBar) {
            menuBar = null;
            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                invalidateIfValid();
                peer.setMenuBar(null);
                m.removeNotify();
            }
            m.parent = null;
        } else {
            super.remove(m);
        }
    }
}
 
Example 2
Source File: Frame.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the menu bar for this frame to the specified menu bar.
 * @param     mb the menu bar being set.
 *            If this parameter is <code>null</code> then any
 *            existing menu bar on this frame is removed.
 * @see       #getMenuBar
 */
public void setMenuBar(MenuBar mb) {
    synchronized (getTreeLock()) {
        if (menuBar == mb) {
            return;
        }
        if ((mb != null) && (mb.parent != null)) {
            mb.parent.remove(mb);
        }
        if (menuBar != null) {
            remove(menuBar);
        }
        menuBar = mb;
        if (menuBar != null) {
            menuBar.parent = this;

            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                menuBar.addNotify();
                invalidateIfValid();
                peer.setMenuBar(menuBar);
            }
        }
    }
}
 
Example 3
Source File: Frame.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame undisplayable by removing its connection
 * to its native screen resource. Making a Frame undisplayable
 * will cause any of its children to be made undisplayable.
 * This method is called by the toolkit internally and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #addNotify
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        FramePeer peer = (FramePeer)this.peer;
        if (peer != null) {
            // get the latest Frame state before disposing
            getState();

            if (menuBar != null) {
                mbManagement = true;
                peer.setMenuBar(null);
                menuBar.removeNotify();
            }
        }
        super.removeNotify();
    }
}
 
Example 4
Source File: Frame.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Makes this Frame displayable by connecting it to
 * a native screen resource.  Making a frame displayable will
 * cause any of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        if (peer == null) {
            peer = getToolkit().createFrame(this);
        }
        FramePeer p = (FramePeer)peer;
        MenuBar menuBar = this.menuBar;
        if (menuBar != null) {
            mbManagement = true;
            menuBar.addNotify();
            p.setMenuBar(menuBar);
        }
        p.setMaximizedBounds(maximizedBounds);
        super.addNotify();
    }
}
 
Example 5
Source File: Frame.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame undisplayable by removing its connection
 * to its native screen resource. Making a Frame undisplayable
 * will cause any of its children to be made undisplayable.
 * This method is called by the toolkit internally and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #addNotify
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        FramePeer peer = (FramePeer)this.peer;
        if (peer != null) {
            // get the latest Frame state before disposing
            getState();

            if (menuBar != null) {
                mbManagement = true;
                peer.setMenuBar(null);
                menuBar.removeNotify();
            }
        }
        super.removeNotify();
    }
}
 
Example 6
Source File: Frame.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the menu bar for this frame to the specified menu bar.
 * @param     mb the menu bar being set.
 *            If this parameter is {@code null} then any
 *            existing menu bar on this frame is removed.
 * @see       #getMenuBar
 */
public void setMenuBar(MenuBar mb) {
    synchronized (getTreeLock()) {
        if (menuBar == mb) {
            return;
        }
        if ((mb != null) && (mb.parent != null)) {
            mb.parent.remove(mb);
        }
        if (menuBar != null) {
            remove(menuBar);
        }
        menuBar = mb;
        if (menuBar != null) {
            menuBar.parent = this;

            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                menuBar.addNotify();
                invalidateIfValid();
                peer.setMenuBar(menuBar);
            }
        }
    }
}
 
Example 7
Source File: Frame.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes the specified menu bar from this frame.
 * @param    m   the menu component to remove.
 *           If <code>m</code> is <code>null</code>, then
 *           no action is taken
 */
public void remove(MenuComponent m) {
    if (m == null) {
        return;
    }
    synchronized (getTreeLock()) {
        if (m == menuBar) {
            menuBar = null;
            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                invalidateIfValid();
                peer.setMenuBar(null);
                m.removeNotify();
            }
            m.parent = null;
        } else {
            super.remove(m);
        }
    }
}
 
Example 8
Source File: Frame.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the menu bar for this frame to the specified menu bar.
 * @param     mb the menu bar being set.
 *            If this parameter is <code>null</code> then any
 *            existing menu bar on this frame is removed.
 * @see       #getMenuBar
 */
public void setMenuBar(MenuBar mb) {
    synchronized (getTreeLock()) {
        if (menuBar == mb) {
            return;
        }
        if ((mb != null) && (mb.parent != null)) {
            mb.parent.remove(mb);
        }
        if (menuBar != null) {
            remove(menuBar);
        }
        menuBar = mb;
        if (menuBar != null) {
            menuBar.parent = this;

            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                menuBar.addNotify();
                invalidateIfValid();
                peer.setMenuBar(menuBar);
            }
        }
    }
}
 
Example 9
Source File: Frame.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame displayable by connecting it to
 * a native screen resource.  Making a frame displayable will
 * cause any of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        if (peer == null) {
            peer = getToolkit().createFrame(this);
        }
        FramePeer p = (FramePeer)peer;
        MenuBar menuBar = this.menuBar;
        if (menuBar != null) {
            mbManagement = true;
            menuBar.addNotify();
            p.setMenuBar(menuBar);
        }
        p.setMaximizedBounds(maximizedBounds);
        super.addNotify();
    }
}
 
Example 10
Source File: Frame.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes the specified menu bar from this frame.
 * @param    m   the menu component to remove.
 *           If <code>m</code> is <code>null</code>, then
 *           no action is taken
 */
public void remove(MenuComponent m) {
    if (m == null) {
        return;
    }
    synchronized (getTreeLock()) {
        if (m == menuBar) {
            menuBar = null;
            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                invalidateIfValid();
                peer.setMenuBar(null);
                m.removeNotify();
            }
            m.parent = null;
        } else {
            super.remove(m);
        }
    }
}
 
Example 11
Source File: Frame.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame undisplayable by removing its connection
 * to its native screen resource. Making a Frame undisplayable
 * will cause any of its children to be made undisplayable.
 * This method is called by the toolkit internally and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #addNotify
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        FramePeer peer = (FramePeer)this.peer;
        if (peer != null) {
            // get the latest Frame state before disposing
            getState();

            if (menuBar != null) {
                mbManagement = true;
                peer.setMenuBar(null);
                menuBar.removeNotify();
            }
        }
        super.removeNotify();
    }
}
 
Example 12
Source File: Frame.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes the specified menu bar from this frame.
 * @param    m   the menu component to remove.
 *           If <code>m</code> is <code>null</code>, then
 *           no action is taken
 */
public void remove(MenuComponent m) {
    if (m == null) {
        return;
    }
    synchronized (getTreeLock()) {
        if (m == menuBar) {
            menuBar = null;
            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                invalidateIfValid();
                peer.setMenuBar(null);
                m.removeNotify();
            }
            m.parent = null;
        } else {
            super.remove(m);
        }
    }
}
 
Example 13
Source File: Frame.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame undisplayable by removing its connection
 * to its native screen resource. Making a Frame undisplayable
 * will cause any of its children to be made undisplayable.
 * This method is called by the toolkit internally and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #addNotify
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        FramePeer peer = (FramePeer)this.peer;
        if (peer != null) {
            // get the latest Frame state before disposing
            getState();

            if (menuBar != null) {
                mbManagement = true;
                peer.setMenuBar(null);
                menuBar.removeNotify();
            }
        }
        super.removeNotify();
    }
}
 
Example 14
Source File: Frame.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame undisplayable by removing its connection
 * to its native screen resource. Making a Frame undisplayable
 * will cause any of its children to be made undisplayable.
 * This method is called by the toolkit internally and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #addNotify
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        FramePeer peer = (FramePeer)this.peer;
        if (peer != null) {
            // get the latest Frame state before disposing
            getState();

            if (menuBar != null) {
                mbManagement = true;
                peer.setMenuBar(null);
                menuBar.removeNotify();
            }
        }
        super.removeNotify();
    }
}
 
Example 15
Source File: Frame.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame undisplayable by removing its connection
 * to its native screen resource. Making a Frame undisplayable
 * will cause any of its children to be made undisplayable.
 * This method is called by the toolkit internally and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #addNotify
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        FramePeer peer = (FramePeer)this.peer;
        if (peer != null) {
            // get the latest Frame state before disposing
            getState();

            if (menuBar != null) {
                mbManagement = true;
                peer.setMenuBar(null);
                menuBar.removeNotify();
            }
        }
        super.removeNotify();
    }
}
 
Example 16
Source File: Frame.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame displayable by connecting it to
 * a native screen resource.  Making a frame displayable will
 * cause any of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        if (peer == null) {
            peer = getToolkit().createFrame(this);
        }
        FramePeer p = (FramePeer)peer;
        MenuBar menuBar = this.menuBar;
        if (menuBar != null) {
            mbManagement = true;
            menuBar.addNotify();
            p.setMenuBar(menuBar);
        }
        p.setMaximizedBounds(maximizedBounds);
        super.addNotify();
    }
}
 
Example 17
Source File: Frame.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame displayable by connecting it to
 * a native screen resource.  Making a frame displayable will
 * cause any of its children to be made displayable.
 * This method is called internally by the toolkit and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #removeNotify
 */
public void addNotify() {
    synchronized (getTreeLock()) {
        if (peer == null) {
            peer = getToolkit().createFrame(this);
        }
        FramePeer p = (FramePeer)peer;
        MenuBar menuBar = this.menuBar;
        if (menuBar != null) {
            mbManagement = true;
            menuBar.addNotify();
            p.setMenuBar(menuBar);
        }
        p.setMaximizedBounds(maximizedBounds);
        super.addNotify();
    }
}
 
Example 18
Source File: Frame.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes this Frame undisplayable by removing its connection
 * to its native screen resource. Making a Frame undisplayable
 * will cause any of its children to be made undisplayable.
 * This method is called by the toolkit internally and should
 * not be called directly by programs.
 * @see Component#isDisplayable
 * @see #addNotify
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        FramePeer peer = (FramePeer)this.peer;
        if (peer != null) {
            // get the latest Frame state before disposing
            getState();

            if (menuBar != null) {
                mbManagement = true;
                peer.setMenuBar(null);
                menuBar.removeNotify();
            }
        }
        super.removeNotify();
    }
}
 
Example 19
Source File: Frame.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the menu bar for this frame to the specified menu bar.
 * @param     mb the menu bar being set.
 *            If this parameter is <code>null</code> then any
 *            existing menu bar on this frame is removed.
 * @see       #getMenuBar
 */
public void setMenuBar(MenuBar mb) {
    synchronized (getTreeLock()) {
        if (menuBar == mb) {
            return;
        }
        if ((mb != null) && (mb.parent != null)) {
            mb.parent.remove(mb);
        }
        if (menuBar != null) {
            remove(menuBar);
        }
        menuBar = mb;
        if (menuBar != null) {
            menuBar.parent = this;

            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                menuBar.addNotify();
                invalidateIfValid();
                peer.setMenuBar(menuBar);
            }
        }
    }
}
 
Example 20
Source File: Frame.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the specified menu bar from this frame.
 * @param    m   the menu component to remove.
 *           If <code>m</code> is <code>null</code>, then
 *           no action is taken
 */
public void remove(MenuComponent m) {
    if (m == null) {
        return;
    }
    synchronized (getTreeLock()) {
        if (m == menuBar) {
            menuBar = null;
            FramePeer peer = (FramePeer)this.peer;
            if (peer != null) {
                mbManagement = true;
                invalidateIfValid();
                peer.setMenuBar(null);
                m.removeNotify();
            }
            m.parent = null;
        } else {
            super.remove(m);
        }
    }
}