Set windows look and feel in java swing application

Setting windows look and feel in a java swing application is easy.This article will explain with the required source code ,how to set windows look and feel for your java swing application.

Go to the class which has the main function. Comment the code for the existing look and feel and add the following code

try {
//javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"); //.getSystemLookAndFeelClassName());
//javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
//javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                  
//The following line of code invokes windows look and feel
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                  
//javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

            } catch (    ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
                  java.util.logging.Logger.getLogger(MainUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }


That is all.

If you liked this article please do leave a reply and share it with friends.

Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.