Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何为JFrame设置颜色_Java_Swing_Jframe_Background Color - Fatal编程技术网

Java 如何为JFrame设置颜色

Java 如何为JFrame设置颜色,java,swing,jframe,background-color,Java,Swing,Jframe,Background Color,粉红色不行 //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.

粉红色不行

//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);

粉红色和其他颜色