I was unable to get anything but metal "look and feel". My code is below. Tried moving segments around without success. Using Windows 8.1.
On Line 9, I set "look and feel" to nimbus but the look was still metal. I know this because I print out that variable on Line 43 and it is still metal. I have 5 possible "look and feel"s but always get metal. Any suggested changes to the code to make it work is most welcome.
Code:
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class TryWindow {
public static void createWindow() {
JFrame aWindow = new JFrame("This is the Window Title");
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
javax.swing.SwingUtilities.updateComponentTreeUI(aWindow);
} catch(Exception e) {
System.err.println("Look and feel not set.");
}
try {
UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName());
javax.swing.SwingUtilities.updateComponentTreeUI(aWindow);
} catch(Exception e) {
System.err.println("Look and feel not set.");
}
int windowWidth = 400;
int windowHeight = 150;
aWindow.setBounds(50,100, windowWidth, windowHeight);
aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
aWindow.setVisible(true);
}
public static void main(String[] args) {
UIManager.LookAndFeelInfo[] looks = UIManager.getInstalledLookAndFeels();
for(UIManager.LookAndFeelInfo look : looks) {
System.out.println(look.getClassName());
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createWindow();
}
});
System.out.println(UIManager.getCrossPlatformLookAndFeelClassName());
}
}