Reputation: 19
JPanel mygame = new JPanel();
mygame.setLayout(new BorderLayout());
mygame.add(new JButton("Start Game"),
mygame.setForeground(Color.red);
BorderLayout.WEST);
This is how I input the code, and I tried diff ways following tutorials but colour of "start game" text will not change. also set background to gray but it stays default color? Can't see what I'm doing wrong, followed tutorial only changed bits for my specific code? help appreciated
Upvotes: 1
Views: 1784
Reputation: 29282
Instead of changing the foreground colour of JPanel
, change the foreground colour of JButton
JButton button = new JButton("Start Game")
JPanel mygame = new JPanel();
button.setForeground(Color.red);
mygame.setLayout(new BorderLayout());
mygame.add(button);
Upvotes: 1