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

  • SEARCH
  • Home
  • 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 7747139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:27:23+00:00 2026-06-01T10:27:23+00:00

I have a problem with a Context menu in JavaFx 2:it never disappers when

  • 0

I have a problem with a Context menu in JavaFx 2:it never disappers when I left click on the graph of the JFXPanel

Does anybody knows how to solve this problem?

Thanks

Here is my code

 final ContextMenu cm = new ContextMenu();
            MenuItem chartItem1 = new MenuItem("Chart Settings");

            cm.getItems().add(chartItem1);

            getScene().setOnMouseReleased(new EventHandler<MouseEvent>()  {
        @Override
        public void handle(MouseEvent mouseEvent) {
            if(cm.isShowing()){
                cm.hide();
            }
            if(mouseEvent.getButton() == MouseButton.SECONDARY)
            {
                cm.show(getScene().getRoot(), mouseEvent.getScreenX(), mouseEvent.getScreenY());
            }
        }
    });
            chartItem1.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent t) {
                    dialogs.ChartFormat  cs = new dialogs.ChartFormat(null, true);                
                    cs.setLocationRelativeTo(null);
                    cs.setVisible(true);                
                }
              });
  • 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-06-01T10:27:24+00:00Added an answer on June 1, 2026 at 10:27 am

    Reproduced the described behavior. Don’t know the reason but you can use ContextMenu#hide():

    final ContextMenu cm = new ContextMenu();  
    
    MenuItem menuItem = new MenuItem("Item 1");
    menuItem.addEventHandler(EventType.ROOT, new EventHandler<Event>() {
    
            @Override
            public void handle(Event t) {
                SwingUtilities.invokeLater(new Runnable() {
    
                    @Override
                    public void run() {
                        JPanel messagePane = new JPanel();
                        messagePane.add(new JLabel("label"));
                        JDialog jDialog = new JDialog();
                        jDialog.getContentPane().add(messagePane);
                        jDialog.pack();
                        jDialog.setVisible(true);
                    }
                });
            }
        });
    cm.getItems().add(menuItem);
    
    scene.setOnMouseReleased(new EventHandler<MouseEvent>() {
        @Override
                public void handle(MouseEvent mouseEvent) {
                    // if(cm.isShowing())
                    cm.hide();
                    if (mouseEvent.getButton() == MouseButton.SECONDARY) {
                        cm.show(lineChart, mouseEvent.getScreenX(), mouseEvent.getScreenY());
                    }
                }
            });
    

    Also you can check out these links:
    http://pixelduke.wordpress.com/2011/12/11/popupmenu-in-javafx/
    http://javafx-jira.kenai.com/browse/RT-17853
    http://javafx-jira.kenai.com/browse/RT-14899

    Adding sample code to your question would be more descriptive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is how to switch from context menu to correct activity. I have
i have a problem while using jquery context menu and update panels. i am
I have a context menu in wp7 <toolkit:ContextMenuService.ContextMenu> <toolkit:ContextMenu x:Name=onHoldContextMenu> <toolkit:MenuItem Header=Delete Tag={Binding} Click=DeleteVisitorNote_Click
I want to render using Richfaces a context menu on left click on a
I have a problem setting an image to the custom context menu item in
I have a problem when binding a command in a context menu on a
So I made my own right click context menu, and I have expandable options
I have a problem with flash content in IE7 being always over the menu
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have a problem with long urls in the context of video streaming via

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.