User Interface Options for the Java Developer

Java user interface options. Stylised diagram of computers.

Last week I discussed an answer to a survey question we asked a while ago. The survey question was:
“If you could have a one-on-one teaching session with me, what are the two topics or questions about Java that you would ask me?”

One of the responses we received was:
“Which Java topic (class) must I explore to build/enhance my cross platform development skill set?”

I thought about all the skills a Java programmer might need for cross-platform development. And that led to last week’s post about full-stack developers.

Today I want to look at the user interface options for the Java developer.

Separation of Concerns

One of the first things we learn in object orientaton is the idea of “separation of concerns”. Each class should be responsible for one and only one thing.

This permeates up into our architectural decisions as well. Each larger building block component should have one and only one responsibility. This leads to N-tier architectures. We have tiers for user interface components, tiers for business components, tiers for cacheing components, tiers for database components, tiers for pooling components, etc.

In most enterprise applications, the tiers behind the user interface will be the same, regardless of the user interface chosen. The choice of user interface determines a major scope of work when writing a cross-platform application in Java.

Java User Interface Options

There are two major approaches to developing a user interface front-end for a Java application:

  • Rich client graphical user interface (GUI).
  • Web-based user interface (UI).

The user interface front-end can communicate with the back-end using a variety of technologies. These include REST/SOAP web services, RMI/RMI-IIOP, CORBA, HTTP, raw sockets, etc. This will not significantly affect the development of the front-end.

Rich Client Graphical User Interface

If you want to write rich client GUI front-ends in Java, you’ll need to use a GUI framework. You’ll probably have to decide between AWT, Swing and JavaFX. These are all well-supported Java-based technologies. You can use whichever GUI framework you like.

AWT (Abstract Windowing Toolkit

AWT has been around since Java 1.0, but is outdated and has portability issues. AWT uses native peer code that has platform specific limitations. The AWT components are generally referred to as heavyweight components because of the native peer code. Some components may not function at all depending on the OS platform. Older GUI applications have mainly been written using AWT.

Swing

Swing has been part of the Java Standard Edition since Java 1.2. Swing is more portable than AWT. It has a pure Java design that has fewer platform specific limitations. Swing has more sophisticated graphical components that aren’t limited by the native peers that AWT uses. Swing components are often described as lightweight because they do not need native resources to be allocated in the operating system’s windowing toolkit. The majority of existing Java GUI applications are based on Swing.

JavaFX

JavaFX was intended to replace Swing as the standard GUI library for Java SE. It has a number of advantages over Swing. These include being more lightweight, having CSS styling, sophisticated design controls, and the use of FXML (to develop the GUI layout using XML) and Scene Builder. JavaFX isn’t just an alternative to web-based development; it’s a viable alternative to other toolkits for building GUI desktop/mobile applications. From Java 11, JavaFX is a standalone component that must be downloaded separately. JavaFX is part of the open-source OpenJDK, under the OpenJFX project. The majority of new Java GUI applications are based on JavaFX.

JavaFXPorts

JavaFXPorts is the open source project that brings Java and JavaFX to mobile and embedded hardware, including iPhone, iPad, Android devices, and the Raspberry Pi. Gluon (a third-party development house) provides free IDE plugins and JavaFXPorts builds, as well as commercial support.

Swing and JavaFX are interoperable. JavaFX components can be used to enhance Swing applications, though you’d probably be better served by choosing either one or the other.

Since the JDK 11 release in 2018, JavaFX supports Linux, Windows, MacOS, Android, iOS, and embedded Raspberry Pi. Swing supports only the first three platforms.

Third-party user interface options

There are other third-party libraries that can be used to develop rich client GUI applications in Java, such as SWT (Standard Widget Toolkit, now maintained by the Eclipse Foundation). A potential problem with using third party libraries is finding a suitably skilled developer for your team.

Web-based User Interface

Front-end developers are responsible for a website or application’s user-facing elements. These include the user interface (UI), visual presentation and browser compatibility issues (for websites). Front-end developers create everything a user sees and experiences when navigating a site.

Front-end technologies that you’d use for a web-based application would definitely include:

  • HTML5 and CSS3.
  • JavaScript.
  • Third-party JavaScript libraries like jQuery, Angular, and ReactJS.

Other possible front-end technologies would depend on the enterprise stack being used. These could include:

  • JavaServer Pages (JSP) and Java/Jakarta Standard Tag Library (JSTL).
  • JavaServer Faces (JSF) and a JSF library like Primefaces, Richfaces, IceFaces, MyFaces, etc.
  • Spring Boot and Spring MVC together with a view technology such as JSP/JSTL, Thymeleaf, Tiles, FreeMarker, Velocity, etc.

Conclusion

A cross-platform enterprise application shouldn’t run into too many difficulties, especially if you use the latest standard Java-based technologies.

Let me know your ideas and comments about enterprise cross-platform development by sharing your comments.

Next week I’ll write about adding mobile operating systems like Android and iOS to the cross-platform mix. That adds a huge amount of complexity to the survey answer.

1 thought on “User Interface Options for the Java Developer”

  1. Pingback: Cross-Platform Mobile App Development for Java Developers • 2022 • Incus Data Programming Courses

Leave a Comment

Your email address will not be published. Required fields are marked *

Code like a Java Guru!

Thank You

We're Excited!

Thank you for completing the form. We're excited that you have chosen to contact us about training. We will process the information as soon as we can, and we will do our best to contact you within 1 working day. (Please note that our offices are closed over weekends and public holidays.)

Don't Worry

Our privacy policy ensures your data is safe: Incus Data does not sell or otherwise distribute email addresses. We will not divulge your personal information to anyone unless specifically authorised by you.

If you need any further information, please contact us on tel: (27) 12-666-2020 or email info@incusdata.com

How can we help you?

Let us contact you about your training requirements. Just fill in a few details, and we’ll get right back to you.

Your Java tip is on its way!

Check that incusdata.com is an approved sender, so that your Java tips don’t land up in the spam folder.

Our privacy policy means your data is safe. You can unsubscribe from these tips at any time.