import javax.swing.JFrame; import javax.swing.JButton; import java.awt.Color; public class SetForeGround extends JFrame{ SetForeGroun...
import javax.swing.JFrame; import javax.swing.JButton; import java.awt.Color; public class SetForeGround extends JFrame{ SetForeGround () { super("JButton Example"); JButton button=new JButton("Click");//create a new button Color c=Color.MAGENTA;//Create color button.setForeground(c);//setbackground color button.setBounds(10, 10, 100,20);//set button location add(button);//add button setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400,400); setVisible(true); } public static void main(String args[]) { new SetForeGround(); } }