javafx.scene.control.SkinBase Java Examples

The following examples show how to use javafx.scene.control.SkinBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TooltipUtil.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void showTooltipIfTruncated(SkinBase skinBase, Labeled labeled) {
    for (Object node : skinBase.getChildren()) {
        if (node instanceof Text) {
            String displayedText = ((Text) node).getText();
            String untruncatedText = labeled.getText();
            if (displayedText.equals(untruncatedText)) {
                if (labeled.getTooltip() != null) {
                    labeled.setTooltip(null);
                }
            } else if (untruncatedText != null && !untruncatedText.trim().isEmpty()) {
                final Tooltip tooltip = new Tooltip(untruncatedText);

                // Force tooltip to use color, as it takes in some cases the color of the parent label
                // and can't be overridden by class or id
                tooltip.setStyle("-fx-text-fill: -bs-rd-tooltip-truncated;");
                labeled.setTooltip(tooltip);
            }
        }
    }
}
 
Example #2
Source File: CssHelper.java    From dolphin-platform with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a StyleableObjectProperty instance that is parametrized by the given parameters. The property will be a <tt>SimpleStyleableObjectProperty</tt>. The returned property must be defined as a field in the Skin class of the given Control class.
 * @param metaData The CssMetaData instance
 * @param skin The Skin that contains the property field.
 * @param <S> Type of the Control
 * @param <V> value type of the property
 * @return a styleable property that can be used in the Skin of a Control
 *
 * @see SimpleStyleableObjectProperty
 */
public static <S extends Control, V> StyleableObjectProperty<V> createProperty(SkinPropertyBasedCssMetaData<S, V> metaData, SkinBase<S> skin) {
    return new SimpleStyleableObjectProperty<V>(metaData, skin, metaData.getPropertyName(), metaData.getInitialValue(skin.getSkinnable()));
}