An ES6 implementation of the Java Swing API (WORK IN PROGRESS!)
swing.js is my personal attempt to bring the power of Java Swing API to the web. swing.js is used in my other projects so its development follows my needs in those projects. As a result, only a very small fraction of all Java Swing specifications are correctly handled.
swing.js is NOT a production ready tool; if you need a professional Java Swing replacement for the web then here is a list of options:
I'm a Java developer, I love Java, I love NetBeans, I love everything in Java, but sadly Java for desktop (and browser) is a mess. On the other hand it is very difficult for an old style Java Swing developer to project UI for the web. So, I decided to rewrite Java Swing in JavaScript (to be more precise in ES6). Only a very limited portion of the Java Swing API has been rewritten (the portion I need for...) and for some objects new methods have been introduced to power up them (see the documentation and test for major details). To distinguish "native" methods and new methods see the documentation, if a method is a clone of a corresponding native method then it is documented as follows
/**
* Clone of javax.swing.<class>.<method>
*
*/
If a method is not available in the original class then a complete documentation is available.
swing.js allows to customize some UI parameters such as fonts and colors, and some components provide special methods to customize the UI (see the documentation and test for major details).
swing.js can be used in two different ways: as a JavaScript library or as a Java library.
If you want to use swing.js as a JavaScript library then simply add it to your project and start to write your UIs in JavaScript with a Java Swing-like approach. To do this, reference the swing-bundle-<version>.js and swing-bundle-<version>.css files (or the corresponding minified versions) available in the build folder.
If you want to use swing.js as a Java library then add the swing-bundle-<version>.jar file to your classpath, write your Java code and then transpille it by means of (for example) josetta (swing.js itself has been written in Java and transpilled in JavaScript by using josetta). If you want you can also create your UIs by means of a visual IDE (for example the NetBeans GUI Builder, codename Matisse). The code provided in the test folder shows some use examples (the resulting output can be tested in the test).
Currently only the English and Italian languages are managed.
swing.js has been tested on:
- desktop
- chrome 124
- edge 124
- firefox 125
- mobile
- chrome 124
- edge 124
swing.js is developed in NetBeans as an ANT project. In order to perform a build you can use ANT, NetBeans or any IDE compatible with ANT.
If you would like to support the development of this and/or other projects, consider making a donation.