My most popular answer on Stack Overflow has to do with Clojure-Java interop. Since that answer was written, some of the tools used in the answer, specifically enclojure, have been deprecated. Because many of the follow-up questions related to how to build a working version of the answer, I thought it might be a good idea to update the post with modern tools.
Every time I update the default JDK used by NetBeans, I also want to update the default JavaFX platform. And I always forget how. Looking on the web usually results in finding methods that just don’t work. Here’s how I do it.
- In NetBeans (7.3 as of this writing), select the “Tools” menu and the “Java Platforms” drop-down menu.
- In the left pane of the dialog, select “Default JavaFX Platform” and remove it. Close the dialog by clicking the “Close” button.
- From the “File” menu, select “New Project…”
- Create a new “JavaFX Application”, then complete the wizard using the defaults supplied.
That will reset the Default JavaFX Platform to point to the version included in the latest JDK.
Most programs written for graphical user interfaces still provide a way to operate with the keyboard, requiring minimal mouse usage. The thought is that expert users will want to speed through their work keeping their fingers on the keyboard rather than devote an entire hands worth of fingers to controlling the mouse. I’ve been learning JavaFX, the eventual replacement for the Swing UI framework on Java, and wanted to explore how shortcut functionality had changed. There were a few tutorials on keyboard shortcuts for menu-driven programs, but nothing I could find on their use with button-based interfaces. That’s what I cover here.
I’ve been experimenting with adding keyboard accelerators to some of the Clojure programs I’ve written with JavaFX-based user interfaces. As part of that investigation, I tried to translate the Java program here to Clojure. The program just puts up a window with a menu bar containing only a “
File” menu which itself contains one item, “
Exit“. Most programs provide a keyboard shortcut or accelerator to close the program with a
Ctrl-X (on Windows). Figuring out how to add that functionality was a bit of an issue for me.