62,614
社区成员
发帖
与我相关
我的任务
分享
import java.awt.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame();
Component p = frame.getGlassPane();
Container pp = frame.getContentPane();
JLayeredPane ppp = frame.getLayeredPane();
JRootPane pppp = frame.getRootPane();
//((JComponent)pp).setOpaque(false); //1
//pppp.setOpaque(false); //2
p.setBackground(Color.YELLOW);
pp.setBackground(Color.BLACK);
ppp.setBackground(Color.GREEN);
pppp.setBackground(Color.BLUE);
frame.setBackground(Color.RED);
frame.setSize(100, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}