Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javafx.scene.control;
import com.sun.javafx.beans.IDProperty;
import javafx.collections.ObservableSet;
import javafx.css.PseudoClass;
import javafx.css.Styleable;
import javafx.css.CssMetaData;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ObjectPropertyBase;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventDispatchChain;
import javafx.event.EventHandler;
import javafx.event.EventTarget;
import javafx.event.EventType;
import javafx.scene.Node;
import javafx.scene.input.KeyCombination;
import com.sun.javafx.event.EventHandlerManager;
import com.sun.javafx.scene.control.ContextMenuContent;
import javafx.scene.control.skin.ContextMenuSkin;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.ObservableMap;
import javafx.scene.Parent;
/**
*
* MenuItem is intended to be used in conjunction with {@link Menu} to provide
* options to users. MenuItem serves as the base class for the bulk of JavaFX menus
* API.
* It has a display {@link #getText() text} property, as well as an optional {@link #getGraphic() graphic} node
* that can be set on it.
* The {@link #getAccelerator() accelerator} property enables accessing the
* associated action in one keystroke. Also, as with the {@link Button} control,
* by using the {@link #setOnAction} method, you can have an instance of MenuItem
* perform any action you wish.
*
* Note: Whilst any size of graphic can be inserted into a MenuItem, the most
* commonly used size in most applications is 16x16 pixels. This is
* the recommended graphic dimension to use if you're using the default style provided by
* JavaFX.
*
* To create a MenuItem is simple:
MenuItem menuItem = new MenuItem("Open");
menuItem.setOnAction(e {@literal ->} System.out.println("Opening Database Connection..."));
Circle graphic = new Circle(8);
graphic.setFill(Color.GREEN);
menuItem.setGraphic(graphic);
Menu menu = new Menu("File");
menu.getItems().add(menuItem);
MenuBar menuBar = new MenuBar(menu);
*
*
*
* @see Menu
* @since JavaFX 2.0
*/
@IDProperty("id")
public class MenuItem implements EventTarget, Styleable {
/* *************************************************************************
* *
* Constructors *
* *
**************************************************************************/
/**
* Constructs a MenuItem with no display text.
*/
public MenuItem() {
this(null,null);
}
/**
* Constructs a MenuItem and sets the display text with the specified text
* @param text the display text
* @see #setText
*/
public MenuItem(String text) {
this(text,null);
}
/**
* Constructor s MenuItem and sets the display text with the specified text
* and sets the graphic {@link Node} to the given node.
* @param text the display text
* @param graphic the graphic node
* @see #setText
* @see #setGraphic
*/
public MenuItem(String text, Node graphic) {
setText(text);
setGraphic(graphic);
styleClass.add(DEFAULT_STYLE_CLASS);
}
/* *************************************************************************
* *
* Instance Variables *
* *
**************************************************************************/
private final ObservableList styleClass = FXCollections.observableArrayList();
final EventHandlerManager eventHandlerManager =
new EventHandlerManager(this);
private Object userData;
private ObservableMap