/* * Copyright (c) 2010, 2014, 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 javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanPropertyBase; import javafx.beans.value.WritableValue; import javafx.event.ActionEvent; import javafx.scene.AccessibleAttribute; import javafx.scene.AccessibleRole; import javafx.scene.Cursor; import javafx.scene.Node; import javafx.css.PseudoClass; import javafx.scene.control.skin.HyperlinkSkin; import javafx.css.StyleableProperty; /** *
An HTML like label which can be a graphic and/or text which responds to rollovers and clicks. * When a hyperlink is clicked/pressed {@link #isVisited} becomes {@code true}. A Hyperlink behaves * just like a {@link Button}. When a hyperlink is pressed and released * a {@link ActionEvent} is sent, and your application can perform some action based on this event. *
* *Example:
* {@code Hyperlink link = new Hyperlink("www.oracle.com"); } * @since JavaFX 2.0 */ public class Hyperlink extends ButtonBase { /*************************************************************************** * * * Constructors * * * **************************************************************************/ /** * Creates a hyperlink with no label. */ public Hyperlink() { initialize(); } /** * Create a hyperlink with the specified text as its label. * * @param text A text string for its label. */ public Hyperlink(String text) { super(text); initialize(); } /** * Create a hyperlink with the specified text and graphic as its label. * * @param text A text string for its label. * @param graphic A graphic for its label */ public Hyperlink(String text, Node graphic) { super(text, graphic); initialize(); } private void initialize() { // Initialize the style class to be 'hyperlink'. getStyleClass().setAll(DEFAULT_STYLE_CLASS); setAccessibleRole(AccessibleRole.HYPERLINK); // cursor is styleable through css. Calling setCursor // makes it look to css like the user set the value and css will not // override. Initializing cursor by calling applyStyle with null // StyleOrigin ensures that css will be able to override the value. ((StyleableProperty