Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7446203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:15:41+00:00 2026-05-29T12:15:41+00:00

I am trying to implement a custom tooltip using the javafx.stage.Popup . The sample

  • 0

I am trying to implement a custom tooltip using the javafx.stage.Popup. The sample demo code is:

public class PopupDemo extends Application {

    private Popup tooltip;
    private final SepiaTone sepiaTone = new SepiaTone();

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

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("PopupDemo");

        Label content = new Label();
        content.setStyle("-fx-background-color:#FCFBBD; -fx-padding: 5; -fx-border-color: #BFBD3B");

        tooltip = new Popup();
        tooltip.getContent().add(content);

        VBox vbox = new VBox(10);
        for (int i = 0; i < 5; i++) {
            final Label lbl = new Label("item " + i);
            lbl.setStyle("-fx-border-color:darkgray; -fx-background-color:lightgray");
            lbl.setMaxSize(80, 60);
            lbl.setMinSize(80, 60);
            lbl.setAlignment(Pos.CENTER);

            lbl.setOnMouseEntered(new EventHandler<MouseEvent>() {

                @Override
                public void handle(final MouseEvent e) {
                    lbl.setEffect(sepiaTone);
                    lbl.setStyle("-fx-cursor: hand");
                    Label content = (Label) tooltip.getContent().get(0);
                    content.setText(lbl.getText());
                    tooltip.show(lbl, e.getScreenX(), e.getScreenY());
                }
            });
            lbl.setOnMouseExited(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent e) {
                    lbl.setEffect(null);
                    lbl.setStyle("-fx-cursor: default");
                    tooltip.hide();
                }
            });

            vbox.getChildren().add(lbl);
        }

        StackPane root = new StackPane();
        root.setPadding(new Insets(20));
        root.getChildren().add(vbox);
        primaryStage.setScene(new Scene(root, 600, 400));
        primaryStage.show();
    }
}

When I move the mouse over the labels the popup shows up and it is working great. But in some cases the two mouse event handlers OnMouseEntered and OnMouseExited are being called continuously one after another. One can reproduce this by running provided example, maximising a window and hovering labels continuously.

Is there a way to avoid this? I’m using JavaFX 2.0.1. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:15:43+00:00Added an answer on May 29, 2026 at 12:15 pm

    It’s a classic problem: you put mouse at a point, node receives MouseEntered — tooltip appears under the mouse and covers the node triggering MouseExited.

    To avoid that you can change tooltip.show(lbl, e.getScreenX(), e.getScreenY()) call to

    tooltip.show(lbl, e.getScreenX() + 1, e.getScreenY() + 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement my custom authorize attribute like: public class MyCustomAuth : AuthorizeAttribute
I am trying to implement a custom control using a RowClickableGridView class provided on
I've been trying awhile to implement this mootools tooltip sample on my site, the
I am trying to implement Custom Error handling via Action Filter Attributes. My code
I'm trying to implement a custom combobox options popup, so that near each option
I'm trying to implement a custom class for dataannotations that retrieves error messages from
I am trying to implement a custom titlebar: Here is my Helper class: import
I am trying to implement a custom Java widget using GWT.This requires me to
I am trying to implement a custom Java widget using GWT.This requires me to
I am trying to implement some custom security code into SSRS 2008 (not R2)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.