-2

I am trying to make a simple jFrame for my game in NetBeans, and I've gone to many pages on Stack Overflow and none of the solutions worked, and I've also gone into the Java Article on it. The Java article said that changing the look and feel after adding elements could not work, so I created a new frame to try it out, but it still didn't work. The method everyone is using is going into the look and feel section of the frame source code, and changing

try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Windows".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }

the "Nimbus".equals(info.getName()); to whatever feel you want, and I've changed mine to windows. This still didn't work. Does anyone know how I could fix/solve this?

Anonymous
  • 169
  • 2
  • 6

2 Answers2

1

if you are trying to set WindowsLookAndFeel then simply replace

try {
    for (javax.swing.UIManager.LookAndFeelInfo info :     javax.swing.UIManager.getInstalledLookAndFeels()) {
        if ("Windows".equals(info.getName())) {
            javax.swing.UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }

by

 try {
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    }

and for more changes relevant to other platforms, follow the pattern given in the image below. Details Provided by Oracle Docs for further details visit this link.

JAMSHAID
  • 1,258
  • 9
  • 32
0

info.getName().contains("Windows") and this best is done already in the main, before GUI elements are created. Otherwise you need to notify the GUI hierarchy for a new design.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138