I'm currently working on a GUI-heavy application, one that uses JInternalFrame to have multiple smaller windows open in one instance of JDesktopPane, and I'm trying to personalize the look of the Nimbus Look and Feel. I can easily change Primary and Secondary colours, but I'm running into trouble when I try to change individual components, the current culprit being JLabel text.
This is the method I'm using to both set the LnF, and customize it:
(Apologies in advance if I bollox up the codeblock)
protected static void GUIStyle() throws Exception
{
//Setting GUI styling
UIManager.put("nimbusBase", new Color(255, 128, 0));
UIManager.put("control", new Color(65, 105, 255));
//UIManager.put("textForeground", Color.WHITE);
try
{
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
{
if ("Nimbus".equals(info.getName()))
{
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
}
catch (Exception e)
{
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
UIManager.getLookAndFeelDefaults().put("MenuItem[Enabled].textForeground", Color.WHITE);
UIManager.getLookAndFeelDefaults().put("MenuBar:Menu[Enabled].textForeground", Color.WHITE);
}
Now, I'm trying to make the text on every JLabel in the application white, but I can't seem to pin down the specific component that does it, even with this handy list.
Adding
UIManager.getLookAndFeelDefaults().put("InternalFrame.foreground", Color.WHITE);
didn't work.
Neither did
UIManager.getLookAndFeelDefaults().put("Label.foreground", Color.WHITE);
I'm stumped. It's obviously doable, because I can change all of the text to white by adding
UIManager.put("text", Color.WHITE);
before I set the Look and Feel. But given the circumstances, I only need the JLabel text to be white, not absolutely every piece of text.
Thank you in advance. If you could explain why exactly I'm having trouble with this (or point me to the proper resource explaining why) I'd love to see it. I'm having similar problems with other components as well, but I'm hoping that if I can get to the bottom of this one, I can figure out the others.