00 Votes

Java: Swing application should use operating system theme

Question by Guest | 13.05.2018 at 23:29

When I create a program using Java, the Widget Toolkit "Swing" is used for the GUI. The problem is that you can see that your app has this typical Java interface.

What can I do to make the program appear more native in style? Is there a way to just use the standard style or the default theme of the operating system?

1Best Answer1 Vote

To get the look and feel of your operating system in your Java program, you can use the following code right at the beginning of your main:

public static void main(String[] args) {

  String  style;
  style = javax.swing.UIManager.getSystemLookAndFeelClassName(); 

  try {
  } catch(Exception e) {     
      style = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
  } finally {

  // other code

In the case of an exception, that is, when the loading of the standard theme goes awry, the nimbus design is used.
14.05.2018 at 13:33

ReplyPositive Negative

Related Topics

What is the best Operating System?
Open Voting | 7 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.