modules/controls/src/main/java/javafx/scene/control/ContextMenu.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization


  26 package javafx.scene.control;
  27 
  28 import com.sun.javafx.beans.IDProperty;
  29 import javafx.beans.property.ObjectProperty;
  30 import javafx.beans.property.ObjectPropertyBase;
  31 import javafx.collections.ListChangeListener.Change;
  32 import javafx.collections.ObservableList;
  33 import javafx.event.ActionEvent;
  34 import javafx.event.Event;
  35 import javafx.event.EventHandler;
  36 import javafx.geometry.HPos;
  37 import javafx.geometry.Point2D;
  38 import javafx.geometry.Side;
  39 import javafx.geometry.VPos;
  40 import javafx.scene.Node;
  41 import javafx.scene.Scene;
  42 import javafx.stage.Window;
  43 
  44 import com.sun.javafx.util.Utils;
  45 import com.sun.javafx.collections.TrackableObservableList;
  46 import com.sun.javafx.scene.control.skin.ContextMenuSkin;
  47 import javafx.beans.property.BooleanProperty;
  48 import javafx.beans.property.SimpleBooleanProperty;
  49 
  50 /**
  51  * <p>
  52  * A popup control containing an ObservableList of menu items. The {@link #items}
  53  * ObservableList allows for any {@link MenuItem} type to be inserted,
  54  * including its subclasses {@link Menu}, {@link MenuItem}, {@link RadioMenuItem}, {@link CheckMenuItem} and
  55  * {@link CustomMenuItem}. If an arbitrary Node needs to be
  56  * inserted into a menu, a CustomMenuItem can be used. One exception to this general rule is that
  57  * {@link SeparatorMenuItem} could be used for inserting a separator.
  58  * <p>
  59  * A common use case for this class is creating and showing context menus to
  60  * users. To create a context menu using ContextMenu you can do the
  61  * following:
  62 <pre><code>
  63 final ContextMenu contextMenu = new ContextMenu();
  64 contextMenu.setOnShowing(new EventHandler&lt;WindowEvent&gt;() {
  65     public void handle(WindowEvent e) {
  66         System.out.println("showing");




  26 package javafx.scene.control;
  27 
  28 import com.sun.javafx.beans.IDProperty;
  29 import javafx.beans.property.ObjectProperty;
  30 import javafx.beans.property.ObjectPropertyBase;
  31 import javafx.collections.ListChangeListener.Change;
  32 import javafx.collections.ObservableList;
  33 import javafx.event.ActionEvent;
  34 import javafx.event.Event;
  35 import javafx.event.EventHandler;
  36 import javafx.geometry.HPos;
  37 import javafx.geometry.Point2D;
  38 import javafx.geometry.Side;
  39 import javafx.geometry.VPos;
  40 import javafx.scene.Node;
  41 import javafx.scene.Scene;
  42 import javafx.stage.Window;
  43 
  44 import com.sun.javafx.util.Utils;
  45 import com.sun.javafx.collections.TrackableObservableList;
  46 import javafx.scene.control.skin.ContextMenuSkin;
  47 import javafx.beans.property.BooleanProperty;
  48 import javafx.beans.property.SimpleBooleanProperty;
  49 
  50 /**
  51  * <p>
  52  * A popup control containing an ObservableList of menu items. The {@link #items}
  53  * ObservableList allows for any {@link MenuItem} type to be inserted,
  54  * including its subclasses {@link Menu}, {@link MenuItem}, {@link RadioMenuItem}, {@link CheckMenuItem} and
  55  * {@link CustomMenuItem}. If an arbitrary Node needs to be
  56  * inserted into a menu, a CustomMenuItem can be used. One exception to this general rule is that
  57  * {@link SeparatorMenuItem} could be used for inserting a separator.
  58  * <p>
  59  * A common use case for this class is creating and showing context menus to
  60  * users. To create a context menu using ContextMenu you can do the
  61  * following:
  62 <pre><code>
  63 final ContextMenu contextMenu = new ContextMenu();
  64 contextMenu.setOnShowing(new EventHandler&lt;WindowEvent&gt;() {
  65     public void handle(WindowEvent e) {
  66         System.out.println("showing");