22 Votes

Java: Swing application should use operating system theme

Question by Guest | Last update on 2022-07-27 | Created on 2018-05-13

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?

3Best Answer3 Votes

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.
Last update on 2022-07-27 | Created on 2018-05-14

ReplyPositive Negative

Related Topics

Android Splash Screen Tutorial

Tutorial | 0 Comments

What is Swing Trading?

Info | 0 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.