Reputation:
How can I remove any look and feel on my JFrame application to make the controls look like default windows controls ?
Screenshot of what I'm looking for
Upvotes: 1
Views: 1563
Reputation: 462
You can customize the Look & Feel using
UIManager.setLookAndFeel("path.to.lookAndFeel");
Optionally, you can also retrieve the Look & Feel from the system your program is operating on:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
I haven't tested it yet, but if the default Windows Look & Feel is what you want to achieve, I'd recommend trying
com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel
Exceptions included, the full code would be
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
}
catch (UnsupportedLookAndFeelException e) {
// handle exception
}
catch (ClassNotFoundException e) {
// handle exception
}
catch (InstantiationException e) {
// handle exception
}
catch (IllegalAccessException e) {
// handle exception
}
(In case the above doesn't work, you might want to check what's installed, using
public static UIManager.LookAndFeelInfo[] getInstalledLookAndFeels()
)
Upvotes: 0
Reputation: 12217
The class JFrame belongs to the Swing Framework (so what you are creating actually is a "Swing Application" not a "JFrame Application") and seeing that you attached the nimbus tag you seem to have activated the Nimbus Look and Feel. If you want to achieve a native look, you need to set the system look and feel (see MadProgrammers answer written in the meantime).
Upvotes: 0
Reputation: 347332
You can specify the look and feel you want to use. I personally prefer to default to the "system" look and feel, which defaults to the OS specific implementation (Windows on Windows)
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
}
}
}
Do this BEFORE you load any other UI elements
You should also have a look at How to Set the Look and Feel for more details
Upvotes: 2