我在全屏时遇到了问题:我创建了一个框架并将其放在全屏窗口中,但我只看到框架背景的颜色。
这是我使用的代码:
PB frame = new PB();
win = new Window(frame);
gs.setFullScreenWindow(win);
frame.setVisible(true);
frame.repaint();
win.repaint();
和 PB 类,我的框架:
 public class PB extends JFrame
{
    PB()
    {
        super();
        this.setBackground(Color.BLUE);
        this.getContentPane().add(new JButton("button"));
        JPanel jp = new JPanel();
        jp.setBackground(Color.red);
        jp.setSize(360, 200);
        this.getContentPane().add(jp);
        this.setVisible(true);
        repaint();
        pack();
    }
    @Override
    public void paint(Graphics g)
    {
        Graphics2D g2d = (Graphics2D)g;
        g2d.setPaint(new Color(0,0,0));
        g.fillRect(0,0,200,200);
    }
}
所以我所能看到的,是一个带有背景颜色的大屏幕(这里是蓝色);
感谢所有帮助