Java Tooltip(java.lang.String text) Constructor

Syntax

Tooltip(java.lang.String text) constructor from Tooltip has the following syntax.

public Tooltip(java.lang.String text)

Example

In the following code shows how to use Tooltip.Tooltip(java.lang.String text) constructor.


// w  ww .jav a  2  s  . co  m

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Tooltip;
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.setTitle("Tooltip Sample");
        stage.setWidth(300);
        stage.setHeight(150);

        Button button = new Button("Hover Over Me");
        button.setTooltip(new Tooltip("Tooltip for Button"));
        
        ((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