0

I want to create ChoiceBox which I want to call when I press the image below. Is there any to call ChoiceBox menu when I click on the image?

ChoiceBox cb = new ChoiceBox();
        cb.setItems(FXCollections.observableArrayList(
            "New Document", "Open ",
            new Separator(), "Save", "Save as")
        );

enter image description here

Peter Penzov
  • 1,126
  • 134
  • 430
  • 808

1 Answers1

2

You can initially put the ChoiceBox in your pane and set the visibility as false

cb.setVisible(false);

Later, when you click on the image, you can set the visibility as true !

image.setOnAction(new EventHandler<>{
    put void onAction()
    {
       cb.setVisible(true);
    }
});

Note : I just typed the code, so not sure whether it will compile or not ! Just wanted to give you an idea !

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176