How to get the windows native look in Java GUI programming?

Solution 1:

Use the following:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

Read UIManager and How to Set the Look and Feel for more information.

Solution 2:

Try this....

The syntax is:

UIManager.setLookAndFeel(PLAF); (Pluggable Look and Feel)

So, you must include the below 3 lines.

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

SwingUtilities.updateComponentTreeUI(frame);

updateComponentTreeUI(frame);

SwingUtilities.updateComponentTreeUI(frame) is used for refreshing the frame after the change.