is there a specific way to change the look and feel of a swing application without needing to restart the application every time the LAF got changed by the user?
im looking for a solution where one can select the LAF from a configuration dialog and it changes directly on apply without having to fall back to telling the user to restart the application.
currently i remember the selected LAF in a properties file and set it on startup before any window has been opened.
From the Java tutorial:
You first need to set the new look and feel by calling UIManager.setLookAndFeel
:
UIManager.setLookAndFeel(lnfName);
Then, in order to make existing componentes reflect the new look and feel, call the SwingUtilities.updateComponentTreeUI
method on each top-level container (dialogs, frames..). You might also wish to resize each top-level container to adapt to changes in the size of its contained components:
SwingUtilities.updateComponentTreeUI(frame); // update components
frame.pack(); // adapt container size if required
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With