*********************************************************************
COMPLETE SOURCE CODE FOR : ChangeMetalLookAndFeelColor.java
*********************************************************************
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.ColorUIResource;
import javax.swing.*;
import java.awt.FlowLayout;
public class ChangeMetalLookAndFeelColor
{
public ChangeMetalLookAndFeelColor()
{
JFrame.setDefaultLookAndFeelDecorated(true);
MetalLookAndFeel.setCurrentTheme(new OrangeTheme());
JFrame frame=new JFrame("Orange Theme");
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(new JButton("JButton"));
frame.getContentPane().add(new JCheckBox("JCheckBox"));
frame.getContentPane().add(new JTextField("JTextField"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[]args)
{
ChangeMetalLookAndFeelColor cmlafm=new ChangeMetalLookAndFeelColor();
}
class OrangeTheme extends DefaultMetalTheme
{
//NEW COLOR FOR METAL LOOK AND FEEL
ColorUIResource primary1=new ColorUIResource(255,215,76);
ColorUIResource primary2=new ColorUIResource(255,198,0);
ColorUIResource primary3=new ColorUIResource(205,162,11);
ColorUIResource secondary1=new ColorUIResource(255,187,57);
ColorUIResource secondary2=new ColorUIResource(255,168,0);
ColorUIResource secondary3=new ColorUIResource(255,214,104);
//NEW COLOR FOR METAL LOOK AND FEEL
protected ColorUIResource getPrimary1()
{
return primary1;
}
protected ColorUIResource getPrimary2()
{
return primary2;
}
protected ColorUIResource getPrimary3()
{
return primary3;
}
protected ColorUIResource getSecondary1()
{
return secondary1;
}
protected ColorUIResource getSecondary2()
{
return secondary2;
}
protected ColorUIResource getSecondary3()
{
return secondary3;
}
}
}
*********************************************************************
JUST COMPILE AND EXECUTE IT
*********************************************************************