1 /* 2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 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 com.sun.javafx.scene.control.skin; 27 28 import javafx.scene.Node; 29 import javafx.scene.control.Label; 30 import javafx.scene.control.Skin; 31 import javafx.scene.control.Tooltip; 32 33 /** 34 * CSS based skin for Tooltip. It deals mostly with show hide logic for 35 * Popup based controls, and specifically in this case for tooltip. It also 36 * implements some of the Skin interface methods. 37 * 38 * TooltipContent class is the actual skin implementation of the tooltip. 39 */ 40 public class TooltipSkin implements Skin<Tooltip> { 41 private Label tipLabel; 42 43 private Tooltip tooltip; 44 45 public TooltipSkin(Tooltip t) { 46 this.tooltip = t; 47 tipLabel = new Label(); 48 tipLabel.contentDisplayProperty().bind(t.contentDisplayProperty()); 49 tipLabel.fontProperty().bind(t.fontProperty()); 50 tipLabel.graphicProperty().bind(t.graphicProperty()); 51 tipLabel.graphicTextGapProperty().bind(t.graphicTextGapProperty()); 52 tipLabel.textAlignmentProperty().bind(t.textAlignmentProperty()); 53 tipLabel.textOverrunProperty().bind(t.textOverrunProperty()); 54 tipLabel.textProperty().bind(t.textProperty()); 55 tipLabel.wrapTextProperty().bind(t.wrapTextProperty()); 56 tipLabel.minWidthProperty().bind(t.minWidthProperty()); 57 tipLabel.prefWidthProperty().bind(t.prefWidthProperty()); 58 tipLabel.maxWidthProperty().bind(t.maxWidthProperty()); 59 tipLabel.minHeightProperty().bind(t.minHeightProperty()); 60 tipLabel.prefHeightProperty().bind(t.prefHeightProperty()); 61 tipLabel.maxHeightProperty().bind(t.maxHeightProperty()); 62 63 // RT-7512 - skin needs to have styleClass of the control 64 // TODO - This needs to be bound together, not just set! Probably should 65 // do the same for id and style as well. 66 tipLabel.getStyleClass().setAll(t.getStyleClass()); 67 tipLabel.setStyle(t.getStyle()); 68 tipLabel.setId(t.getId()); 69 } 70 71 @Override public Tooltip getSkinnable() { 72 return tooltip; 73 } 74 75 @Override public Node getNode() { 76 return tipLabel; 77 } 78 79 @Override public void dispose() { 80 tooltip = null; 81 tipLabel = null; 82 } 83 }