I have been working with Java in Web environments for the past 10 years.
For the first time, a client asked me to develop a financial application that shall be installed on a given PC.
This application must be a standalone application. Knowing Java I thought of Swing...but I also know I have been out of that game for soooooo long :-)
Hence my questions (forgive me if they sound silly):
1) are people still using Swing for standalone Java based applications?
2) is there anything else other than Swing?
3) can you please recommend a book or other resources to freshen up my knowledge of how to design a decent Java based standalone application?
Oracle now promotes JavaFX for developing desktop applications - it is a good toolkit with CSS styling for UI. And has been integrated into Java SE fully since version 8. However, there will be a learning curve.
Another option is to look at platforms like NetBeans RCP if it is a large/rich application to be built.
SCJP 1.4, OCMJEA/SCEA 5.0.
Giovanni De Stefano
posted 5 years ago
Thank you for your reply.
Ultimately I will have to package the application with an installer, which might come with its own java runtime, so I can make the dependency with version 8.
> Ultimately I will have to package the application with an installer, which might come with its own java runtime
Use the new self-contained packaging features of JavaSE:
https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html You can trigger these features using Maven/Gradle/Ant scripts, just google JavaFX Maven Plugin/JavaFX Gradle Plugin.
The packaging features are not JavaFX specific, so it can work for Swing/SWT apps as well, though, in general, for new apps I'd recommend JavaFX development over using the other toolkits (unless you need to base the app on the NetBeans or Eclipse platforms).
> Another concern is it considered to be a "enterprise client" app meaning able to be connect to EJB and stuff? If so Swing may be a better choice for better integration.
I don't think it makes any difference really. I doubt it is going to be easier to connect to back end services using Swing vs JavaFX vs SWT. It will probably be a pretty equal amount of work for each.
I wouldn't recommend connecting directly to EJBs or using the old JEE remote EJB client libraries (e.g. not this: http://www.mastertheboss.com/jboss-server/jboss-as-7/jboss-as-7-remote-ejb-client-tutorial).
Instead use Rest/Akka/WebSockets - something like that.
> The standalone app will need to connect to a couple of DBs, show tables, Is JavaFX still a good choice for this scenario?
Yes JavaFX is still a good pick for this IMO. JavaFX does not have built-in DB connectivity (neither do other Java UI toolkits like Swing/SWT).
There are some things out there which may assist you in your connectivity (for instance http://www.javafxdata.org). But get prepared to do some work yourself.
Here is a really basic JavaFX/JDBC connectivity sample (https://gist.github.com/jewelsea/4955598), though if you are doing a lot of database work, you are probably better doing it with JPA and a traditional Spring/JEE server and communicating with that over the network from your JavaFX client.
JavaFX has a TableView component https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/table-view.htm which has a lot of functionality. Just don't expect it to have all the functionality of an Excel spreadsheet or a Microsoft Access Database backed table widget.
If you require that more advanced database backed spreadsheet style of stuff, you might want to look for an existing Swing component you could embed using a JavaFX Swing Node, or something like TiwulFX might be able to help: http://tiwulfx.panemu.com. But in all, none of these Java UI toolkits are quite like the old Delphi/MS Access/PowerBuilder systems which helped you to build certain kinds of applications in a RAD environment. For instance, you won't be able to create this in six lines of code: http://www.infoworld.com/article/2631597/development-tools/new-sybase-powerbuilder-12-requires-little-coding.html. Be prepared to write some code, possibly a lot of it and it is going to take time and skill.
> and most likely some graphs. Is JavaFX still a good choice for this scenario?
Yes JavaFX is still a good pick for this IMO. JavaFX has a built-in graphing library.
http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/charts.htm The built-in JavaFX charts look great and are very easy to use for basic charting purposes.
The charts include the ability to listen to changes on observable data sources and animate visual chart changes based upon that.
The charts are also fully stylable via CSS (just like everything else in JavaFX):
If you require full scientific charts, you could use a JavaFX => Java2D bridge (which is actually simple and painless) + JFreeChart/OrsonCharts
http://java.dzone.com/announcements/fxgraphics2d-bridge-java2d Though I'd tend to stick with the built-in JavaFX charts rather than using a bridge if the functionality in the standard JavaFX charts is enough.
Giovanni De Stefano
posted 5 years ago
Hello again John,
you are a rock star ! :-)
I started development of the backend (Spring Boot, JPA, REST) and at the same time I am almost half way through "Apress JavaFX 8 Introduction by Example 2nd edition".
Your help is very much appreciated!
Something about .... going for a swim. With this tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop