写了一个简单的java 小程序,但是为什么设置背景色不能生效呢?
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class EndingListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Color;
public class FirstJFrame
{
public static void main(String[] args)
{
JFrame window = new JFrame();
window.setSize(500, 500);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton closeButton = new JButton("click the button to end close window");
EndingListener listener = new EndingListener();
closeButton.addActionListener(listener);
                  window.getContentPane().setBackground(Color.BLACK); window.getContentPane().add(closeButton);
window.setVisible(true);
                
}
}