I am learning java graphics from a book. I wrote this code and I wanted it to color the background with pinkColor and background of the Button with purpleColor, but the output is completely purple. How can I fix it? and also how can I apply f1 to a to have HELLO with Font f1 in output.
import java.awt.color.*;
import java.awt.*;
import javax.swing.*;
public class First {
public static void main(String[] args) {
Color purpleColor = new Color(120, 78, 140);
Color pinkColor = new Color(120, 13, 14);
String a ="HELLO";
Font f1 = new Font(a, Font.BOLD + Font.ITALIC + Font.CENTER_BASELINE, 25);
JFrame f = new JFrame();
f.setSize(900,600);
JButton b = new JButton(a);
b.setSize(400,200);
f.setBackground(pinkColor);
b.setBackground(purpleColor);
f.add(b);
f.setVisible(true);
}
}
See comments in code for details.