< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1996, 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
  23  * questions.
  24  */
  25 
  26 package java.awt;
  27 
  28 import java.awt.peer.PopupMenuPeer;
  29 import javax.accessibility.*;
  30 


  31 
  32 import sun.awt.AWTAccessor;
  33 
  34 /**
  35  * A class that implements a menu which can be dynamically popped up
  36  * at a specified position within a component.
  37  * <p>
  38  * As the inheritance hierarchy implies, a {@code PopupMenu}
  39  *  can be used anywhere a {@code Menu} can be used.
  40  * However, if you use a {@code PopupMenu} like a {@code Menu}
  41  * (e.g., you add it to a {@code MenuBar}), then you <b>cannot</b>
  42  * call {@code show} on that {@code PopupMenu}.
  43  *
  44  * @author      Amy Fowler
  45  */
  46 public class PopupMenu extends Menu {
  47 
  48     private static final String base = "popup";
  49     static int nameCounter = 0;
  50 
  51     transient boolean isTrayIconPopup = false;
  52 
  53     static {
  54         AWTAccessor.setPopupMenuAccessor(
  55             new AWTAccessor.PopupMenuAccessor() {
  56                 public boolean isTrayIconPopup(PopupMenu popupMenu) {
  57                     return popupMenu.isTrayIconPopup;
  58                 }
  59             });
  60     }
  61 
  62     /*
  63      * JDK 1.1 serialVersionUID
  64      */
  65     private static final long serialVersionUID = -4620452533522760060L;
  66 
  67     /**
  68      * Creates a new popup menu with an empty name.
  69      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
  70      * returns true.
  71      * @see java.awt.GraphicsEnvironment#isHeadless


   1 /*
   2  * Copyright (c) 1996, 2016, 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
  23  * questions.
  24  */
  25 
  26 package java.awt;
  27 
  28 import java.awt.peer.PopupMenuPeer;

  29 
  30 import javax.accessibility.AccessibleContext;
  31 import javax.accessibility.AccessibleRole;
  32 
  33 import sun.awt.AWTAccessor;
  34 
  35 /**
  36  * A class that implements a menu which can be dynamically popped up
  37  * at a specified position within a component.
  38  * <p>
  39  * As the inheritance hierarchy implies, a {@code PopupMenu}
  40  *  can be used anywhere a {@code Menu} can be used.
  41  * However, if you use a {@code PopupMenu} like a {@code Menu}
  42  * (e.g., you add it to a {@code MenuBar}), then you <b>cannot</b>
  43  * call {@code show} on that {@code PopupMenu}.
  44  *
  45  * @author      Amy Fowler
  46  */
  47 public class PopupMenu extends Menu {
  48 
  49     private static final String base = "popup";
  50     static int nameCounter = 0;
  51 
  52     transient volatile boolean isTrayIconPopup;
  53 
  54     static {
  55         AWTAccessor.setPopupMenuAccessor(
  56             new AWTAccessor.PopupMenuAccessor() {
  57                 public boolean isTrayIconPopup(PopupMenu popupMenu) {
  58                     return popupMenu.isTrayIconPopup;
  59                 }
  60             });
  61     }
  62 
  63     /*
  64      * JDK 1.1 serialVersionUID
  65      */
  66     private static final long serialVersionUID = -4620452533522760060L;
  67 
  68     /**
  69      * Creates a new popup menu with an empty name.
  70      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
  71      * returns true.
  72      * @see java.awt.GraphicsEnvironment#isHeadless


< prev index next >