TextField provides a default context menu, as shown in Figure 12-39, that can be displayed by clicking the right mouse button. Menu items are enabled or disabled based on the context. You can replace the default context menu with a custom context menu. Currently, there is no way to customize the default context menu.

9781484211434_Fig12-39.jpg

Figure 12-39. The default context menu for TextField

The following snippet of code sets a custom context menu for a TextField. It displays a menu item stating that the context menu is disabled. Selecting the menu item does nothing. You will need to add an ActionEvent handler to the menu items in context menu to perform some action. ...

Get Learn JavaFX 8: Building User Experience and Interfaces with Java 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.