Blog

Webinar: Automating Java Swing Modernization with Vaadin's Toolkit

By  
Lilli Salo
Lilli Salo
·
On Jul 30, 2024 1:50:00 PM
·

Struggling with outdated Java Swing applications that are slow, have poor user interfaces, and consume excessive resources? Enterprise application modernization is more efficient with Vaadin’s Modernization Toolkit.

In a recent webinar, Ben Wilson demonstrated how to automate the modernization of legacy Java Swing applications to Vaadin Flow.

Vaadin Flow is a full-stack framework that allows developers to build web apps entirely in Java, without needing HTML or JavaScript. Its simplicity enables you to extend existing Java code effortlessly. Ben mentioned that up to 50% of your code can be mapped to Vaadin Flow without changes!

The Vaadin Modernization Toolkit simplifies the migration process, automating up to 80% of the code transformation, saving time and reducing costs.

Read on for webinar highlights or watch the full recording on YouTube.

What is the Vaadin Modernization Toolkit?

The Vaadin Modernization Toolkit is an automation support framework for transforming Swing and Vaadin 7 or 8 applications into modern Vaadin Flow-based web applications. 

There are many approaches to Java modernization. You can start with one (or several) proof-of-concept projects before tackling your main app. You can take a phased approach, or you can start directly. Regardless of your approach, any modernization project requires three tooling pillars to be successful.

  1. Assess—Quantify dependencies, assess impact, estimate effort
  2. Coexist—Phased modernization planning
  3. Transform—Automated refactoring of existing Java code.

The Modernization Toolkit accelerates the transformation phase, reducing developer effort by up to 80%.

Screenshot 2024-07-23 at 16.57.41

Understanding the code transformation process

Transforming your Java code means removing references in your application to legacy code or libraries that you want to move away from. For example, if you have 10 Swing buttons in your application, you must replace them all as part of the modernization process.

References in a Java application come from two primary sources—invocations and types.

Invocations

In the typical application, 80% of the references come from invocations to legacy libraries. Developers look for invocations of methods or constructors and find the class that declares the method. If the class is in the library that they want to move away from, they have to remove or rewrite it.

Types

Sometimes, the application code could subclass a type in the legacy library—for example, implementing the interface defined in the library, casting to a type, using the type as a type argument in a collection, or just declaring a local variable in a method. Any place in the application code that references a type declared in the library that you're moving away from also requires transformation.

How Vaadin Modernization Toolkit works

Automated application modernization in the toolkit takes a bottom-up approach and works by understanding the total references in your code and how many are suitable for automation. It supports the process in two ways.

Automated refactoring

The Dragonfly transpiler in the toolkit performs the automated code refactoring. The software takes the legacy Java source code as its input and produces an equivalent modernized Vaadin Flow version. The Dragonfly transpiler generates output that humans can read and work with. It retains white space, indentation, variable names, comments, etc., that support code comprehension. It gives almost line-by-line correspondence between the input and output so developers can quickly get the Dragonfly output into production-ready code.

See below an example code transformation from a sample Java Swing app (left) to Vaadin Flow (right).

Automatic conversion from java swing to web

Feature packs

The feature pack in the Modernization toolkit offers a different perspective on legacy code semantics. Beyond emulating APIs, it identifies and isolates specific behavior that doesn't exist in modern app development. The feature pack highlights old UI code that you won't find if you write a brand new application from scratch today.

For example, the Swing code often references a popup dialog box that freezes the rest of the application and forces the user to acknowledge by clicking the Okay button. Modern web apps replace this with notifications in the background. The transpiler output replaces such code with feature pack code so developers can quickly find and redesign those UI aspects—or leave them in if relevant.

Fine-tuning the toolkit

For the toolkit to really work for your unique project, the Vaadin team offers fine-tuning based on statistical analysis of your codebase. For example, let’s say our analysis shows that the transpiler and the feature pack handle 75% of reference removal.

Our team analyzes the remaining 25% of references and determines the time and cost needed to implement removal in Dragonfly just for you. We give several options for optimum cost-benefit analysis, such as ten days to go from 75-80% and 50 days for 75-90%. We also offer fixed cost and money-back guarantees so you can be more in control of your modernization planning and budgeting.

Take the first step with our Modernization Toolkit Analyzer

Looking to modernize your legacy Java applications? The free Modernization Toolkit Analyzer audits your application’s dependencies and estimates how much of the transformation can be automated. While not a replacement for expert opinion, it provides a solid foundation for discussions with your stakeholders.

Available as a Maven plugin in the Vaadin directory and the Eclipse Marketplace, the Modernization Toolkit Analyzer saves time, reduces risk, and helps you modernize with confidence. Try it today and streamline your Java migration!

Run the Analyzer using your preferred tool on Maven or Eclipse.

Lilli Salo
Lilli Salo
Lilli joined Vaadin in 2021 after delivering content for various international SaaS startups. She enjoys the creative challenge of transforming complicated topics into clear and concise written material that provide value to the reader.
Other posts by Lilli Salo