src/java.desktop/share/classes/java/awt/MenuBar.java

Print this page




 126     }
 127 
 128     /**
 129      * Construct a name for this MenuComponent.  Called by getName() when
 130      * the name is null.
 131      */
 132     String constructComponentName() {
 133         synchronized (MenuBar.class) {
 134             return base + nameCounter++;
 135         }
 136     }
 137 
 138     /**
 139      * Creates the menu bar's peer.  The peer allows us to change the
 140      * appearance of the menu bar without changing any of the menu bar's
 141      * functionality.
 142      */
 143     public void addNotify() {
 144         synchronized (getTreeLock()) {
 145             if (peer == null)
 146                 peer = Toolkit.getDefaultToolkit().createMenuBar(this);
 147 
 148             int nmenus = getMenuCount();
 149             for (int i = 0 ; i < nmenus ; i++) {
 150                 getMenu(i).addNotify();
 151             }
 152         }
 153     }
 154 
 155     /**
 156      * Removes the menu bar's peer.  The peer allows us to change the
 157      * appearance of the menu bar without changing any of the menu bar's
 158      * functionality.
 159      */
 160     public void removeNotify() {
 161         synchronized (getTreeLock()) {
 162             int nmenus = getMenuCount();
 163             for (int i = 0 ; i < nmenus ; i++) {
 164                 getMenu(i).removeNotify();
 165             }
 166             super.removeNotify();




 126     }
 127 
 128     /**
 129      * Construct a name for this MenuComponent.  Called by getName() when
 130      * the name is null.
 131      */
 132     String constructComponentName() {
 133         synchronized (MenuBar.class) {
 134             return base + nameCounter++;
 135         }
 136     }
 137 
 138     /**
 139      * Creates the menu bar's peer.  The peer allows us to change the
 140      * appearance of the menu bar without changing any of the menu bar's
 141      * functionality.
 142      */
 143     public void addNotify() {
 144         synchronized (getTreeLock()) {
 145             if (peer == null)
 146                 peer = getComponentFactory().createMenuBar(this);
 147 
 148             int nmenus = getMenuCount();
 149             for (int i = 0 ; i < nmenus ; i++) {
 150                 getMenu(i).addNotify();
 151             }
 152         }
 153     }
 154 
 155     /**
 156      * Removes the menu bar's peer.  The peer allows us to change the
 157      * appearance of the menu bar without changing any of the menu bar's
 158      * functionality.
 159      */
 160     public void removeNotify() {
 161         synchronized (getTreeLock()) {
 162             int nmenus = getMenuCount();
 163             for (int i = 0 ; i < nmenus ; i++) {
 164                 getMenu(i).removeNotify();
 165             }
 166             super.removeNotify();