import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.TextField; import javafx.scene.control.Tooltip; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.stage.Stage; public class TooltipSample extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { double h = 300; double w = 400; double positionX = w / 2 - 70; double positionY = h / 2 - 30; TextField TextBox_a = new TextField(); TextBox_a.setText("JavaFX"); TextBox_a.setPrefColumnCount(6); TextBox_a.setFocusTraversable(false); TextBox_a.setTranslateX(positionX + 20); TextBox_a.setTranslateY(positionY + 40); Tooltip tooltip2 = new Tooltip(); ImageView imageview2 = new ImageView(); imageview2.setFitWidth(20.0); imageview2.setFitHeight(20.0); imageview2.setImage(new Image("images/duke.gif")); tooltip2.setGraphic(imageview2); tooltip2.setText("Tooltip with Image and Text "); TextBox_a.setTooltip(tooltip2); stage.setTitle("Tooltip Test"); Group group = new Group(); Scene scene = new Scene(group, w, h); ((javafx.scene.Group) scene.getRoot()).getChildren().clear(); ((javafx.scene.Group) scene.getRoot()).getChildren().addAll(TextBox_a); stage.setScene(scene); stage.show(); } }