How FXML Works
FXML works by exploring the Java API, using reflection (or using specialized constructor classes). For more information on how FXML works, see the Introduction to FXML documentation .
Why ContextMenus cannot be defined in panels in JavaFX using FXML markup
contextMenu. A ScrollPane - . , StackPane, . , contextMenu, contextMenu FXML.
.
ContextMenu FXML
( , ) , contextMenu show API, , FXML.
@FXML StackPane stack;
public void initialize() {
final ContextMenu contextMenu = new ContextMenu(new MenuItem("xyzzy"));
stack.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
contextMenu.show(
stack,
mouseEvent.getScreenX(),
mouseEvent.getScreenY()
);
}
});
}
ContextMenu
Node contextMenu, ContextMenus Panes FXML Markup.
, Node contextMenu, Control , ContextMenu . ContextMenu node , JavaFX ( ), . Java, JavaFX, ( , ).
, , SceneBuilder, JavaFX ( , ).