javaswinglook-and-feeluimanagersynth

Making several synth LookAndFeels coexist at the same time in a java swing application


I am working on a java swing application using synth Look and Feel. There are already styles for every possible swing component

I must change the whole application's LookAndFeel, redefining different styles for every possible swing component.

I am now working on a sandbox, launched outside of the application. The sandbox loads my new set of styles, while the application still loads the old ones. No problems for now

However, I must then integrate it 'progressively' in the application. Meaning that in the same java application, some HMIs must use the old set of styles, while some must use the new ones

The difficulty being that each set of styles define synth "region" styles that automatically apply to the corresponding component, and I don't know how deal with several region styles that correspond to the same component type

Anybody has an idea of how I can do this ? I saw that in swing's UIManager, one can change the LookAndFeel, but it then changes for the whole application

Only workaround I saw on the internet was to change the LookAndFeel before instanciating a Component, then change it back, which looks like an awful solution

Thanks in advance


Solution

  • Thank you all for your answers and sorry for my lack of reactivity during the holidays

    I think I found a solution, which is not exactly what I asked for but answers my problem :

    I will not make several LookAndFeels coexist. Instead, I will load all styles, new and old, in the same LookAndFeel, and use different setName() for new and old components For region styles (which was the problematic here), I will make a custom SynthStyleFactory which will redirect to the correct region style

    Once all HMIs are migrated, I will delete the old styles and the custom factory which won't be needed anymore