【发布时间】:2012-09-17 18:24:34
【问题描述】:
我遇到了全屏问题:我创建了一个框架并将其放在全屏窗口中,但我只看到框架背景的颜色。
这是我使用的代码:
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);
}
}
所以我能看到的只有一个背景颜色(这里是蓝色)的大屏幕;
感谢大家的帮助
【问题讨论】:
标签: java swing jpanel fullscreen paint