With no code at all, you can paste text contents from another program into your javafx.scene.control.TextField using key commands (Cmd-Shift-V on a Mac). Similarly, you can copy and cut from your TextFields. However, most applications have a MenuBar that is an alternative to the keyboard shortcuts. This blog post shows how to interact with the System Clipboard to get and put text into TextFields using MenuBar commands. This is also the foundation for more complex Clipboard operations such as those involving binary data.
Featured Post
Applying Email Validation to a JavaFX TextField Using Binding
This example uses the same controller as in a previous post but adds a use case to support email validation. A Commons Validator object is ...
Tuesday, October 28, 2014
Saturday, October 25, 2014
JavaFX and the Delegate Pattern
The declarative power of SceneBuilder and CSS in today's Java desktop gives you flexibility and control over your UI separate from the Java code.
But these new artifacts -- the FXML of SceneBuilder and CSS -- need to be integrated in your app design using more than just JavaFX Controllers. The FXML can become fragmented, requiring extra Java code to tie the fragments together. Or, you'll have a monolithic FX program that will be difficult to maintain.
This blog post advocates for applying the Delegate Pattern to your Java FX app in conjunction with an expansive usage of FXML. While you can refactor your way into the Delegate Pattern (do it later from a large Controller), it's far better to do this on the onset because the wiring and creating of Delegates will be cleaner.
But these new artifacts -- the FXML of SceneBuilder and CSS -- need to be integrated in your app design using more than just JavaFX Controllers. The FXML can become fragmented, requiring extra Java code to tie the fragments together. Or, you'll have a monolithic FX program that will be difficult to maintain.
This blog post advocates for applying the Delegate Pattern to your Java FX app in conjunction with an expansive usage of FXML. While you can refactor your way into the Delegate Pattern (do it later from a large Controller), it's far better to do this on the onset because the wiring and creating of Delegates will be cleaner.
Wednesday, October 22, 2014
JavaFX Tabbed Navigation
In today's touch-oriented desktop applications, tabbed navigation can provide a better user experience than heavyweight windows. With a single-click on a tab, the user navigates to a new application view without shuffling a second modeless window. Moreover, the tab allows the user to see the previous view and allows for quick switching between the tabs.
In JavaFX, a requirement like this is implemented using the TabPane class which contains a list of active Tabs. In this demonstration, FXML from SceneBuilder will describe a whole tab structure and the program will manage the additional and removal of tabs from the pane.
Note that there will only by one tab object of a kind in memory at one time.
Monday, October 20, 2014
Access Restriction in Eclipse: The Type FXML is not API
When upgrading to Java 8, I noticed that all the FX references in my Java source were flagged with a warning in my Eclipse IDE (including the latest, Luna). This warning is caused by shipping FX as an extension rather than a co-located JAR. Since most projects stick to one Java compiler (Oracle versus IBM), this can be safely turned off.
Thursday, October 16, 2014
Java FX Notification Overlays
This post presents a Java FX program that uses overlays to notify the user of a validation error. The solution is FXML-driven and uses an off-the-shelf Scene Builder Alert Template with no modifications.
Monday, October 6, 2014
Code-Free Swipe to a View Controller
In your Cocoa Touch app, you can swipe to a UIViewController using only the Storyboard. No Objective-C or Swift code is required.
Subscribe to:
Posts (Atom)