我有一个全屏的问题:我创建一个框架,并把它放在一个全屏窗口,但我什么都看不到框架的背景的颜色。框架不显示全屏
这里是我使用的代码:
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);
}
}
因此,所有我所看到的,是一个大屏幕的背景颜色(这里的蓝色);
感谢所有帮助
Fro引用,工作[sscce](http://sscce.org/)可能会找到[这里](http://stackoverflow.com/a/7457102/230513)。 – trashgod
该框架确实全屏显示,你只是画一个彩色的矩形... – brimborium
非常感谢你! sscce让我走出了坑 – IonOne