So I am new to Netbeans and Swing GUI development in general and I am trying to change the Look and Feel of a JFrame. When I create a JFrame form Netbeans by default make it Nimbus theme.
I tried to change to the Windows theme (if ("Windows".equals(info.getName())) {
) and the Metal theme (if ("Metal".equals(info.getName())) {
) and it worked flawlessly with these 2 themes.
But when I try to change it to the Dark Nimbus theme (if ("Dark Nimbus".equals(info.getName())) {
) it didn't work.
I also tried doing Right Click > Preview Design > Dark Nimbus and yes it previews the Dark Nimbus theme as expected. But not when I actually compile and run the program (by clicking the play button).
Does anyone know how to change the theme to "Dark Nimbus"?
Here is the relevant code:
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Dark Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TestGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TestGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TestGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TestGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
Dark Nimbus
You mean the Sith? No.. wait.. that'sDarth Nimbus
. What'sDark Nimbus
? BTW - did you consider printing all the alternatives and looking at what is available? – Andrew Thompson