Java Reference
In-Depth Information
copyWorker.cancel(true);
14-12. Associating Keyboard Sequences
with Applications
Problem
You want to create keyboard shortcuts for menu options.
Solution
Create an application that will use JavaFX's key combination APIs. The main classes
you will be using are shown here:
javafx.scene.input.KeyCode
javafx.scene.input.KeyCodeCombination
javafx.scene.input.KeyCombination
The following source code listing is an application that displays the available key-
board shortcuts that are bound to the menu items. When the user performs a keyboard
shortcut, the application will display the key combination on the screen:
public void start(Stage primaryStage) {
primaryStage.setTitle("Chapter 14-12 Associating
Keyboard Sequences");
Group root = new Group();
Scene scene = new Scene(root, 530, 300, Color.WHITE);
final StringProperty statusProperty = new
SimpleStringProperty();
InnerShadow iShadow = new InnerShadow();
iShadow.setOffsetX(3.5f);
iShadow.setOffsetY(3.5f);
Search WWH ::




Custom Search