src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 309             }
 310             return null;
 311         }
 312     }
 313 
 314     /**
 315      * Returns showing submenu, if any
 316      */
 317     XMenuPeer getShowingSubmenu() {
 318         synchronized(getMenuTreeLock()) {
 319             return showingSubmenu;
 320         }
 321     }
 322 
 323     /**
 324      * Adds item to end of items vector.
 325      * Note that this function does not perform
 326      * check for adding duplicate items
 327      * @param item item to add
 328      */
 329     @SuppressWarnings("deprecation")
 330     public void addItem(MenuItem item) {
 331         XMenuItemPeer mp = (XMenuItemPeer)item.getPeer();
 332         if (mp != null) {
 333             mp.setContainer(this);
 334             synchronized(getMenuTreeLock()) {
 335                 items.add(mp);
 336             }
 337         } else {
 338             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 339                 log.fine("WARNING: Attempt to add menu item without a peer");
 340             }
 341         }
 342         updateSize();
 343     }
 344 
 345     /**
 346      * Removes item at the specified index from items vector.
 347      * @param index the position of the item to be removed
 348      */
 349     public void delItem(int index) {
 350         synchronized(getMenuTreeLock()) {
 351             if (selectedIndex == index) {


   1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 309             }
 310             return null;
 311         }
 312     }
 313 
 314     /**
 315      * Returns showing submenu, if any
 316      */
 317     XMenuPeer getShowingSubmenu() {
 318         synchronized(getMenuTreeLock()) {
 319             return showingSubmenu;
 320         }
 321     }
 322 
 323     /**
 324      * Adds item to end of items vector.
 325      * Note that this function does not perform
 326      * check for adding duplicate items
 327      * @param item item to add
 328      */

 329     public void addItem(MenuItem item) {
 330         XMenuItemPeer mp = AWTAccessor.getMenuComponentAccessor().getPeer(item);
 331         if (mp != null) {
 332             mp.setContainer(this);
 333             synchronized(getMenuTreeLock()) {
 334                 items.add(mp);
 335             }
 336         } else {
 337             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 338                 log.fine("WARNING: Attempt to add menu item without a peer");
 339             }
 340         }
 341         updateSize();
 342     }
 343 
 344     /**
 345      * Removes item at the specified index from items vector.
 346      * @param index the position of the item to be removed
 347      */
 348     public void delItem(int index) {
 349         synchronized(getMenuTreeLock()) {
 350             if (selectedIndex == index) {