< prev index next >

modules/controls/src/main/java/javafx/scene/control/skin/ButtonSkin.java

Print this page




   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 javafx.scene.control.skin;
  27 

  28 import com.sun.javafx.scene.control.behavior.BehaviorBase;
  29 import com.sun.javafx.scene.control.skin.Utils;
  30 import javafx.scene.Node;
  31 import javafx.scene.Scene;
  32 import javafx.scene.control.Button;
  33 import javafx.scene.control.ContextMenu;
  34 import com.sun.javafx.scene.control.behavior.ButtonBehavior;
  35 import javafx.scene.control.Control;
  36 import javafx.scene.input.KeyCode;
  37 import javafx.scene.input.KeyCodeCombination;
  38 
  39 /**
  40  * Default skin implementation for the {@link Button} control.
  41  *
  42  * @see Button
  43  * @since 9
  44  */
  45 public class ButtonSkin extends LabeledSkinBase<Button> {
  46 
  47     /***************************************************************************
  48      *                                                                         *
  49      * Private fields                                                          *
  50      *                                                                         *
  51      **************************************************************************/
  52 
  53     private KeyCodeCombination defaultAcceleratorKeyCodeCombination;
  54     private KeyCodeCombination cancelAcceleratorKeyCodeCombination;
  55     private final BehaviorBase<Button> behavior;
  56 
  57 
  58 
  59     /***************************************************************************
  60      *                                                                         *
  61      * Listeners                                                               *
  62      *                                                                         *
  63      **************************************************************************/
  64 
  65     Runnable defaultButtonRunnable = () -> {
  66         if (getSkinnable().getScene() != null && getSkinnable().impl_isTreeVisible() && !getSkinnable().isDisabled()) {
  67             getSkinnable().fire();
  68         }
  69     };
  70 
  71     Runnable cancelButtonRunnable = () -> {
  72         if (getSkinnable().getScene() != null && getSkinnable().impl_isTreeVisible() && !getSkinnable().isDisabled()) {
  73             getSkinnable().fire();
  74         }
  75     };
  76 
  77 
  78 
  79     /***************************************************************************
  80      *                                                                         *
  81      * Constructors                                                            *
  82      *                                                                         *
  83      **************************************************************************/
  84 
  85     /**
  86      * Creates a new ButtonSkin instance, installing the necessary child
  87      * nodes into the Control {@link Control#getChildren() children} list, as
  88      * well as the necessary input mappings for handling key, mouse, etc events.
  89      *
  90      * @param control The control that this skin should be installed onto.
  91      */
  92     public ButtonSkin(Button control) {




   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 javafx.scene.control.skin;
  27 
  28 import com.sun.javafx.scene.NodeHelper;
  29 import com.sun.javafx.scene.control.behavior.BehaviorBase;
  30 import com.sun.javafx.scene.control.skin.Utils;
  31 import javafx.scene.Node;
  32 import javafx.scene.Scene;
  33 import javafx.scene.control.Button;
  34 import javafx.scene.control.ContextMenu;
  35 import com.sun.javafx.scene.control.behavior.ButtonBehavior;
  36 import javafx.scene.control.Control;
  37 import javafx.scene.input.KeyCode;
  38 import javafx.scene.input.KeyCodeCombination;
  39 
  40 /**
  41  * Default skin implementation for the {@link Button} control.
  42  *
  43  * @see Button
  44  * @since 9
  45  */
  46 public class ButtonSkin extends LabeledSkinBase<Button> {
  47 
  48     /***************************************************************************
  49      *                                                                         *
  50      * Private fields                                                          *
  51      *                                                                         *
  52      **************************************************************************/
  53 
  54     private KeyCodeCombination defaultAcceleratorKeyCodeCombination;
  55     private KeyCodeCombination cancelAcceleratorKeyCodeCombination;
  56     private final BehaviorBase<Button> behavior;
  57 
  58 
  59 
  60     /***************************************************************************
  61      *                                                                         *
  62      * Listeners                                                               *
  63      *                                                                         *
  64      **************************************************************************/
  65 
  66     Runnable defaultButtonRunnable = () -> {
  67         if (getSkinnable().getScene() != null && NodeHelper.isTreeVisible(getSkinnable()) && !getSkinnable().isDisabled()) {
  68             getSkinnable().fire();
  69         }
  70     };
  71 
  72     Runnable cancelButtonRunnable = () -> {
  73         if (getSkinnable().getScene() != null && NodeHelper.isTreeVisible(getSkinnable()) && !getSkinnable().isDisabled()) {
  74             getSkinnable().fire();
  75         }
  76     };
  77 
  78 
  79 
  80     /***************************************************************************
  81      *                                                                         *
  82      * Constructors                                                            *
  83      *                                                                         *
  84      **************************************************************************/
  85 
  86     /**
  87      * Creates a new ButtonSkin instance, installing the necessary child
  88      * nodes into the Control {@link Control#getChildren() children} list, as
  89      * well as the necessary input mappings for handling key, mouse, etc events.
  90      *
  91      * @param control The control that this skin should be installed onto.
  92      */
  93     public ButtonSkin(Button control) {


< prev index next >