我有一個全屏的問題:我創建一個框架,並把它放在一個全屏窗口,但我什麼都看不到框架的背景的顏色。框架不顯示全屏
這裏是我使用的代碼:
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