Reputation: 43
I have set the look and feel nimbus in my java application, but i dont know why the view is always different from one frame to other. in a frame I got perfectly good blue nimbus, and in other frame I got the grey one but that's not proper. and the other one was not displayed as using nimbus look and feel. here's the code that I use in main
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
I also import
import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
I hope somebody can help me, thank you.
Upvotes: 0
Views: 1505
Reputation: 36601
When you switch from one Look and feel to another, you must make sure to invoke the SwingUtilities#updateComponentTreeUI
method once for each top-level container. Also, if you store UI components which are not part of any visible UI/top-level container, you will have to update those as well.
For example if your second panel was already created when you switch look-and-feel, make sure to update it as well.
There is, like for almost anything in Swing, a rather good tutorial available
Upvotes: 5