Java Tooltip .setContentDisplay (ContentDisplay value)

Syntax

Tooltip.setContentDisplay(ContentDisplay value) has the following syntax.

public final void setContentDisplay(ContentDisplay value)

Example

In the following code shows how to use Tooltip.setContentDisplay(ContentDisplay value) method.


import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
//  w ww  .j a  va 2  s. com

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.setContentDisplay(ContentDisplay.BOTTOM);
        
        button.setTooltip(toolTip); 
        ((Group) scene.getRoot()).getChildren().add(button);

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




















Home »
  Java Tutorial »
    javafx.scene.control »




Accordion
Button
CheckBox
CheckMenuItem
ChoiceBox
ComboBox
ContextMenu
Label
Menu
ProgressBar
ToggleButton
ToolBar
Tooltip
TreeItem
TreeView