javafx.scene.control.Tooltip#setShowDuration ( )源码实例Demo

下面列出了javafx.scene.control.Tooltip#setShowDuration ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MyBox   文件: FxmlControl.java
public static void setTooltip(final Node node, Node tip) {
    if (node instanceof Control) {
        removeTooltip((Control) node);
    }
    Tooltip tooltip = new Tooltip();
    tooltip.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
    tooltip.setGraphic(tip);
    tooltip.setShowDelay(Duration.millis(10));
    tooltip.setShowDuration(Duration.millis(360000));
    tooltip.setHideDelay(Duration.millis(10));
    Tooltip.install(node, tooltip);
}
 
源代码2 项目: MyBox   文件: FxmlControl.java
public static void setTooltip(final Node node, final Tooltip tooltip) {
    if (node instanceof Control) {
        removeTooltip((Control) node);
    }
    tooltip.setFont(new Font(AppVariables.sceneFontSize));
    tooltip.setShowDelay(Duration.millis(10));
    tooltip.setShowDuration(Duration.millis(360000));
    tooltip.setHideDelay(Duration.millis(10));
    Tooltip.install(node, tooltip);
}
 
源代码3 项目: phoebus   文件: DataCell.java
/**
 * Constructor. Takes the column index that the cell belongs to.
 * @param col_idx
 */
public DataCell(final int col_idx)
{
    this.col_idx = col_idx;
    
    tooltip = new Tooltip();
    tooltip.setShowDelay(Duration.millis(250));
    tooltip.setShowDuration(Duration.seconds(30));
}
 
源代码4 项目: phoebus   文件: Viewer3d.java
/**
 * Install valid comments onto node.
 *
 * <p> Valid comments must begin and end with double quotes (").
 *
 * @param node
 * @param comment
 * @throws Exception on error.
 */
private static void installComment(final Node node, final String comment) throws Exception
{
    final String content = checkAndParseComment(comment);

    final Tooltip tt = new Tooltip(content);
    tt.setShowDelay(SHOW_QUICKLY);
    tt.setShowDuration(SHOW_FOREVER);
    Tooltip.install(node, tt);
}
 
源代码5 项目: phoebus   文件: TooltipSupport.java
/** Attach tool tip
 *  @param node Node that should have the tool tip
 *  @param tooltip_property Tool tip to show
 *  @param pv_value Supplier of formatted "$(pv_value)". <code>null</code> to use toString of the property.
 */
public static void attach(final Node node, final WidgetProperty<String> tooltip_property, final Supplier<String> pv_value)
{
    if (disable_tooltips)
        return;

    // Patch legacy tool tips that defaulted to pv name & value,
    // even for static widgets
    final StringWidgetProperty ttp = (StringWidgetProperty)tooltip_property;
    if (legacy_tooltip.matcher(ttp.getSpecification()).matches()  &&
        ! tooltip_property.getWidget().checkProperty("pv_name").isPresent())
        ttp.setSpecification("");

    // Suppress tool tip if _initial_ text is empty.
    // In case a script changes the tool tip at runtime,
    // tool tip must have some initial non-empty value.
    // This was done for optimization:
    // Avoid listener and code to remove/add tooltip at runtime.
    if (tooltip_property.getValue().isEmpty())
        return;

    final Tooltip tooltip = new Tooltip();
    tooltip.setWrapText(true);
    // Evaluate the macros in tool tip specification each time
    // the tool tip is about to show
    tooltip.setOnShowing(event ->
    {
        String spec = ((MacroizedWidgetProperty<?>)tooltip_property).getSpecification();

        // Use custom supplier for $(pv_value)?
        // Otherwise replace like other macros, i.e. use toString of the property
        if (pv_value != null)
        {
            final StringBuilder buf = new StringBuilder();
            buf.append(pv_value.get());

            final Object vtype = tooltip_property.getWidget().getPropertyValue(runtimePropPVValue);
            final Alarm alarm = Alarm.alarmOf(vtype);
            if (alarm != null  &&  alarm.getSeverity() != AlarmSeverity.NONE)
                buf.append(", ").append(alarm.getSeverity()).append(" - ").append(alarm.getName());

            final Time time = Time.timeOf(vtype);
            if (time != null)
                buf.append(", ").append(TimestampFormats.FULL_FORMAT.format(time.getTimestamp()));

            spec = spec.replace("$(pv_value)", buf.toString());
        }
        final Widget widget = tooltip_property.getWidget();
        final MacroValueProvider macros = widget.getMacrosOrProperties();
        String expanded;
        try
        {
            expanded = MacroHandler.replace(macros, spec);
            if (expanded.length() > Preferences.tooltip_length)
                expanded = expanded.substring(0, Preferences.tooltip_length) + "...";
            tooltip.setText(expanded);
        }
        catch (Exception ex)
        {
            logger.log(Level.WARNING, "Cannot evaluate tooltip of " + widget, ex);
            tooltip.setText(spec);
        }
    });

    // Show after 250 instead of 1000 ms
    tooltip.setShowDelay(Duration.millis(250));

    // Hide after 30 instead of 5 secs
    tooltip.setShowDuration(Duration.seconds(30));

    Tooltip.install(node, tooltip);
    if (node.getProperties().get(TOOLTIP_PROP_KEY) != tooltip)
        throw new IllegalStateException("JavaFX Tooltip behavior changed");
}