8
This "Lookandfeel" is Nimbus, which netbeans automatically configures when you are using the graphical creation tool it has. To change the LAF(Lookandfeel), just go to the code of main
, and find this passage here:
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
Changing the if line to:
if ("Windows".equals(info.getName()))
or even
if ("Windows Classic".equals(info.getName()))
The first style will try to adapt the appearance to the current version of windows that is running the application, the second will try to adapt to a classic version, similar to windows 98.
It is possible to remove that loop for
within the try/catch
, and make the call below, which will invoke the system theme currently used:
try {
javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
Remembering that, if you run your application in some OS other than windows, java will change to the theme "Metal", which is the only theme "Cross Plataform" that comes embedded in JDK. To have the appearance of windows, independent of the system, you may need create a LAF of its own
At this link there is a list of other existing LAF’s in java-swing.
You can define this using
UIManager#setLookAndFeel
taking the "style" of the OS in which the application is running. But you want your application to have "Windows face" on all operating systems or only on Windows same?– Renan Gomes
Valew man, I’ll try to use
– Rodrigo Storti de Oliveira