Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096443

[ToolTip] The tooltip has an incorrect behavior when the component is at the edge of the screen

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 8
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Labels:

      Description

      Try to run the sample below and move the window to the bottom-right corner of the screen (aligned with the right and bottom edges). Now hover the button and wait for the tooltip to appear.

      You should be able to see that the tooltip will cover the button, and hence will prevent you from clicking on it. Moreover, if you move the mouse away from the button, as opposed to automatically disappearing as it would normally do, the tooltip sticks on the button for a while before it is hidden.

      I'm using Java 8 (build 120) on Windows 7.

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.geometry.Insets;
      import javafx.geometry.Point2D;
      import javafx.geometry.Pos;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Tooltip;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.stage.WindowEvent;


      public class TooltipBugTest extends Application {

          public TooltipBugTest() {
          }


          public static void main(String[] args) {
              Application.launch(args);
          }

          @Override
          public void start(Stage stage) {
           final Tooltip tooltip = new Tooltip("Tooltip Text");
           final Button btn = new Button("Button");
           btn.setOnAction(new EventHandler<ActionEvent>() {

      public void handle(ActionEvent arg0) {
      System.out.println("Hello World");
      }
      });
           btn.setTooltip(tooltip);
          
           //WORKAROUND:
      // tooltip.setOnShowing(new EventHandler<WindowEvent>() {
      //
      // public void handle(WindowEvent arg0) {
      // Point2D point = btn.localToScene(new Point2D(0, 0));
      // tooltip.setY(btn.getScene().getWindow().getY() + btn.getScene().getY() + point.getY() - 35);
      // }
      // });
          
      VBox vBox = new VBox();
      vBox.setAlignment(Pos.BOTTOM_RIGHT);
      vBox.setPadding(new Insets(2));
      vBox.getChildren().setAll(btn);

              Scene scene = new Scene(vBox, 400, 300);
              stage.setScene(scene);
              stage.setTitle("Tooltip Bug Test");
              stage.show();
          }

      }

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              sbozianjfx Shant Bozian (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: