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

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

源代码1 项目: neural-style-gui   文件: ChoiceView.java
public void setTooltip(String tooltip) {
    this.tooltip = tooltip;
    Tooltip tt = new Tooltip(tooltip);
    tt.setWrapText(true);
    tt.setMaxWidth(300);
    label.setTooltip(tt);
    value.setTooltip(tt);
}
 
源代码2 项目: neural-style-gui   文件: DirectoryView.java
public void setTooltip(String tooltip) {
    this.tooltip = tooltip;
    Tooltip tt = new Tooltip(tooltip);
    tt.setWrapText(true);
    tt.setMaxWidth(300);
    fileButton.setTooltip(tt);
    filePathText.setTooltip(tt);
}
 
源代码3 项目: ShootOFF   文件: ExerciseSlide.java
@Override
public void registerExercise(TrainingExercise exercise) {
	final Tooltip t = new Tooltip(exercise.getInfo().getDescription());
	t.setPrefWidth(500);
	t.setWrapText(true);
	exerciseItemPane.addButton(exercise, exercise.getInfo().getName(), Optional.empty(), Optional.of(t));
}
 
源代码4 项目: ShootOFF   文件: ExerciseSlide.java
@Override
public void registerProjectorExercise(TrainingExercise exercise) {
	final Tooltip t = new Tooltip(exercise.getInfo().getDescription());
	t.setPrefWidth(500);
	t.setWrapText(true);
	projectorExerciseItemPane.addButton(exercise, exercise.getInfo().getName(), Optional.empty(), Optional.of(t));
}
 
源代码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");
}