**********************************************************************
COMPLETE SOURCE CODE FOR : SetJButtonForegroundColorUseUiManager.java
**********************************************************************
import javax.swing.UIManager;
import javax.swing.plaf.ColorUIResource;
import javax.swing.*;
import java.awt.*;
public class SetJButtonForegroundColorUseUiManager
{
public static void main(String[]args)
{
/*
*Create color base on RGB color model
*that will use as JButton foreground color.
*Red=255
*Green=0
*Blue=0
*/
Color foregroundColor=new Color(255,0,0);
//Set JButton foreground color
UIManager.put("Button.foreground",new ColorUIResource(foregroundColor));
//Create a window using JFrame with title ( Set JButton foreground color using UIManager )
JFrame frame=new JFrame("Set JButton foreground color using UIManager");
//Create two button
JButton button1=new JButton("Button 1");
JButton button2=new JButton("Button 2");
//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());
//Add created button into frame
frame.add(button1);
frame.add(button2);
//Set JFrame default close operation
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Set JFrame size
frame.setSize(400,400);
//Make JFrame locate at center
frame.setLocationRelativeTo(null);
//Make JFrame visible
frame.setVisible(true);
}
}
**********************************************************************
JUST COMPILE AND EXECUTE IT
**********************************************************************