I am trying to change the color of a JButton, and after some googling I found that button.setForeground (Color a) should do this, but for some reason it does not work. The color of the button does not change.
This is my code:
import java.awt.Color; import javax.swing.JButton; import javax.swing.JFrame; public class test extends JFrame{ public test(){ super(); setSize(100,100); setVisible(true); JButton x = new JButton(); x.setForeground(Color.BLACK); add(x); } public static void main(String[] args) { new test(); } }
I also tried setBackground (Color a), but that just changed the background of the actual button, not the color inside it.
What am I missing?
source share