Blogging on the Dr. Dobbs's site, Eric Bruno writes about JavaFX's built-in support for JDBC, including the various data formats available through a set of Data Source components, such as relational databases, files, the file system itself, and web-based data. Bruno explains the use of these features in a manner that does not require the writing of much data handling code, employing the JavaFX Composer tool.
Bruno begins his blog with a discussion of the JavaFX Composer with which one can visually lay out components from the NetBeans palette that's located in a pane in the upper right of the screen, providing a link to the NetBeans 6.9 / JavaFX 1.3 bundle for readers who wish to download it. He also includes a screenshot of the JavaFX Composer Palette to illustrate his remarks.
He suggests that the tool is a simple one to use, given that all of the JavaFX layout containers, controls, shapes, effects, charts, data sources, and so on, are available in the palette to be dragged and dropped onto the user's application's Scene.
Bruno goes on to show how to create a Java DB entry within the NetBeans services tab and then choose it as the Connection URL. With screen shots of the Data Source Customizer window, Bruno demonstrates next how to specify a query for the data source.
He next shows how one binds the created list view's data to the results of the query and then how to bind the list view to the data from the JDBC data source.
The next steps in the process are to create a second list view and populate it with the list of library patrons from the database. With these steps completed one has only to include a client JAR file in the project.
For users wishing to refine the code beyond what the JavaFX Composer does on its own, Bruno shows how to examine the raw JavaFX Script that's generated, and how to use it as a starting point in the future. He provides code examples to illustrate scrolling through the generated code.
Once again, Bruno comments on the ease of using JavaFX JDBC Data Source in his remark that, "Since JavaFX Script is a declarative language (as opposed to an imperative language), you simply state what you want to do, and the run-time takes care of how to do it. The rest of the code includes labels and the button, along with some layout, but the JavaFX Script object declarations and the bind statements that connect them do all of the work."
Working with JavaFX Script in doing UI layout and database connectivity are far easier than attempting the same tasks with either Java or Swing, Bruno declares. "Additionally, NetBeans and the JavaFX Composer take it a step further, and make building applications -- even database applications -- as simple as drag-and-drop."
More Information
JavaFX and Why you Should Give It a Try
Creating a Simple Web Application using a MySQL Database
[...read more...]
Other articles in the JavaFX section of Volume 149, Issue 2:
Using the JavaFX JDBC Data Source
(this article)
See all archived articles in the JavaFX section.
|
|
Top 10 Most Popular Articles in Current Issue (Vol 167, Issue 4)
|
|
|
|
|
Recent Blog Entries as of February 4, 2012, 11:53 am |
|
|
|
|
|
|