如何为 JFrame 设置颜色

how to set a Color to an JFrame

粉色不行!

//Frame

JFrame f = new JFrame("Tab");

f.setBounds(100, 100, 1000, 1000);

f.setVisible(true);

f.setLayout(null);

f.setBackground(Color.pink);

您需要改用内容面板。只需替换

f.getContentPane().setBackground(Color.pink);

而不是

f.setBackground(Color.pink);