All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dua3.utility.fx.controls.TooltipConfig Maven / Gradle / Ivy

There is a newer version: 15.0.2
Show newest version
package com.dua3.utility.fx.controls;

import javafx.scene.control.Tooltip;
import javafx.util.Duration;

/**
 * A record holding tooltip durations.
 * @param showDelay the delay before a tooltip is shown after the pointer enters the node
 * @param showDuration how long the tooltip is shown
 * @param hideDelay the delay before the tooltip is hidden when the pointer is moved outside the node
 */
public record TooltipConfig(Duration showDelay, Duration showDuration, Duration hideDelay) {
    private static final TooltipConfig DEFAULT_CONFIG = from(new Tooltip());

    /**
     * Get the configuration with the default values as defined by JavaFX.
     * @return configuration with default values
     */
    public static TooltipConfig getDefault() {
        return DEFAULT_CONFIG;
    }

    /**
     * Apply this configuration to a tooltip.
     * @param tt the tooltip
     */
    public void applyTo(Tooltip tt) {
        tt.setShowDelay(showDelay);
        tt.setShowDuration(showDuration);
        tt.setHideDelay(hideDelay);
    }

    /**
     * Obtain configuration from a tooltip.
     * @param tt the tooltip
     * @return configuration with values from the tooltip
     */
    public static TooltipConfig from(Tooltip tt) {
        return new TooltipConfig(tt.getShowDelay(), tt.getShowDuration(), tt.getHideDelay());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy