I'm trying to allow users to change the applications theme like dark/light etc.
To do this so far I've been using:
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if (newTheme.equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
SwingUtilities.updateComponentTreeUI(getRootPane());
}
});
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
}
I'm not sure I really should even be changing the entire look and feel. The problem with using this method, is I can see no way of setting a jPanel to anything that would change with the theme.
An example of what I mean is something like setting: jPanel 1 to color: menu jpanel 2 to color: background
Where in theme 1, then menu may be grey, and background may be blue. In theme 2 menu would be green and background red as an example