Friday, August 8, 2008

Customise Java Look And Feel

The Java look and feel is the default interface for applications built with the JFC. The Java look and feel is designed for cross-platform use and can provide consistency in the appearance and behavior of common design elements.

The default look and feel is Metal (javax.swing.plaf.metal.MetalLookAndFeel) like this picture.











How to set look and feel (LAF)?

The following code show how to set LAF:

package laf;

import javax.swing.*;

public class Main implements Runnable
{
public void run()
{
try
{
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
catch(Exception e)
{
}
JFrame.setDefaultLookAndFeelDecorated(true);
new MainForm().setVisible(true);
}

public static void main(String args[])
{
SwingUtilities.invokeLater(new Main());
}
}