Since 2019, material-ui-swing has an experimental feature that is called MaterialTheming. In particular, MaterialTheming is a proposal to add a declarative Theme system inside Swing like the material theming system implemented in Flutter or Jetpack Compose.
Introduction to Material-UI-Swing
Material-UI-Swing is a library that gives the possibility to import material style inside a very old framework like Swing with the original swing API. The library was originally born as College Project by atharva washimkar and transformed into a product by vincenzopalazzo.
In addition, the original project was forked by vincenzopalazzo because he started to implement some experiments in his own repository, after that, the repository https://github.com/vincenzopalazzo/material-ui-swing was the only repository maintained, but periodically the atharw's receive synchronization with the last update.
After the original maintainer left the project as maintainer in 2018 and the vincenzopalazzo new maintainer begin in 2018 until now, the scope development of the library start to be to grow as a product. This was also possible by the support from Arizona State University during the integration of the library with one of the most popular Swing software in the world which is JMars.
The development of the library was focused to experiment with some solutions that provide the building blocks for the end developers to implement any type of style that the user wants without using a standard palette built inside the library.
This opens two problems, that are described below:
- Implementing a dynamic component that is able to change with user settings can be difficult because can contain a lot of corner cases.
- Swing framework has no easy concept of theme inside (a theme in the sense of Style and not only colors), but that can also change the style of one component.
Introduction to MaterialTheming System
Material Theming system provided of constant build in the library under a MaterialTheme interface and with this concept to have an interface that provides the access to all the value that Swing process to build and styling the UI material-ui-swing is able to support external theme provided in separate jars that include only the style of the application.
One example of an external theme is DarkStackOverflowTheme, and this is an important feature to have inside a UI toolking.
In contrast, the MaterialTheme interface can be improved and allowed different formats of configuration, by file propriety or JSON, and so on.
This is particularly powerful when the user wants to import some theme from external resources like the Intellij themes or others.
Example of Usage
Change theme is super easy and doesn't require you to make any change inside the repository, you can have inside the static block the following code
static {
try {
// UIManager.setLookAndFeel(new MaterialLookAndFeel(new MaterialLiteTheme()));
// by including the https://github.com/material-ui-swing/DarkStackOverflowTheme
UIManager.setLookAndFeel(new MaterialLookAndFeel(new DarkStackOverflowTheme())); mouse hover
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
Conclusion
After many years I start to share my experiment started on material-ui-swing to implement a custom theme, and implement an alternative library to modernize Swing application.
If you like my work considered to sponsor me on Github sponsor page and follow me on Github @vincenzopalazzo
Top comments (0)