JavaFX Tutorial - Java Tooltip .setTextOverrun (OverrunStyle value)








Syntax

Tooltip.setTextOverrun(OverrunStyle value) has the following syntax.

public final void setTextOverrun(OverrunStyle value)

Example

In the following code shows how to use Tooltip.setTextOverrun(OverrunStyle value) method.

// ww w.j  av a  2 s  .c o  m
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.OverrunStyle;
import javafx.scene.control.Tooltip;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;


public class Main extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        stage.setWidth(300);
        stage.setHeight(150);

        Button button = new Button("Hover Over Me");
        Tooltip toolTip = new Tooltip("Tooltip for Button");
                
        toolTip.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
        
        button.setTooltip(toolTip);        
        
        ((Group) scene.getRoot()).getChildren().add(button);

        stage.setScene(scene);
        stage.show();
    }
}