Java Code Examples for javafx.scene.control.Tooltip#setWrapText()

The following examples show how to use javafx.scene.control.Tooltip#setWrapText() . 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: ChoiceView.java    From neural-style-gui with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: DirectoryView.java    From neural-style-gui with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: ExerciseSlide.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@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));
}
 
Example 4
Source File: ExerciseSlide.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@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));
}
 
Example 5
Source File: TooltipSupport.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** 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");
}