Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025 026package javafx.scene.input; 027 028import javafx.event.ActionEvent; 029import javafx.scene.Node; 030 031/** 032 * This class is used when creating a Mnemonic. 033 * The Mnemonic is constructed with a {@link javafx.scene.Node Node} and a {@link KeyCombination}. 034 * When a Mnemonic is registered on a {@link javafx.scene.Scene Scene}, and the KeyCombination reaches the Scene unconsumed, 035 * then the target Node will be sent an {@link javafx.event.ActionEvent ActionEvent}. 036 * <p> 037 * Controls should use their MnemonicParsing property when adding Mnemonics. 038 * </p> 039 * <p> 040 * Mnemonics will not be displayed on all platforms, but the api 041 * will still be present. 042 * </p> 043 */ 044 045public class Mnemonic { 046 047 /** 048 * Constructs a {@code Mnemonic} with the specified target {@link javafx.scene.Node Node} 049 * and trigger {@link KeyCombination}. 050 * 051 * @param node the {@link javafx.scene.Node Node} that will receive the {@link javafx.event.ActionEvent ActionEvent}. 052 * @param keyCombination the {@link KeyCombination} that will trigger the Mnemonic. 053 */ 054 public Mnemonic(Node node, KeyCombination keyCombination) { 055 this.node = node; 056 this.keyCombination = keyCombination; 057 } 058 059 private KeyCombination keyCombination; 060 /** 061 * Returns the {@link KeyCombination} 062 */ 063 public KeyCombination getKeyCombination() { return keyCombination; } 064 065 /** 066 * Sets the {@link KeyCombination} 067 */ 068 public void setKeyCombination(KeyCombination keyCombination) { 069 this.keyCombination = keyCombination; 070 } 071 072 private Node node; 073 074 /** 075 * Returns the {@link javafx.scene.Node Node} 076 */ 077 public Node getNode() { return node; } 078 079 /** 080 * Sets the {@link javafx.scene.Node Node} 081 */ 082 public void setNode(Node node) { 083 this.node = node; 084 } 085 086 /** 087 * Fire the {@link javafx.event.ActionEvent ActionEvent} 088 */ 089 public void fire() { 090 if (node != null) 091 node.fireEvent(new ActionEvent()); 092 } 093}