D
Der Anfänger
Gast
Warum wird mein Button nicht grün?
Code:
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ButtonAction {
public static void main(String[] args) {
JFrame f = new JFrame();
JButton b1 = new JButton("Hallo Welt");
b1.setForeground(Color.RED);
b1.setBackground(Color.GREEN);
JPanel p = new JPanel();
p.add(b1);
f.add(p);
f.setSize(300, 300);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}