javaeclipsemavenuser-interfacewindowbuilder

Why does my windowbuilder UI look different when i start the program?


im using WindowBuilder to create an UI easily. The problem now: The interface looks different in WindowBuilder and when I run the program as java application. See here: In WindowBuilder

When the program is runned as java application

What can I do to make it look like the WindowBuilder preview when I start the program?


Solution

  • You can alter the overall look of your app by setting a Look and Feel.

     try {
       for (javax.swing.UIManager.LookAndFeelInfo laf : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Classic Windows".equals(laf.getName())) {
                        javax.swing.UIManager.setLookAndFeel(laf.getClassName());
                        break;
                    }
                }
            } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException |
                     IllegalAccessException e) {
                throw new RuntimeException(e);
      }