Using the systems Look And Feel

Using the systems Look And Feel

To make your Java application looking like all other applications on your system you have to use the System's Look And Feel. This tutorial shows how. more >>

Contents

setLookAndFeel

Use the UIManager.setLookAndFeel in the main(String args[])
at the first position.

import javax.swing.*;


public class LookAndFeel {
       public static void main(String[] args){
         //Look and feel
    try {
    // Set System L&F
        UIManager.setLookAndFeel(
        UIManager.getSystemLookAndFeelClassName());
    } 
    catch (Exception e) {
        System.out.println("Cannot set System's Look And Feel!");
    }
    
    JFrame f=new JFrame("System's Look And Feel");
    JButton b=new JButton("Test Button");
    f.getContentPane().add(b);
    f.pack();
    f.setVisible(true);
       }
}