2
我有一个名为TPanel
的JPanel
分机,该分机在JFrame
的右侧绘制了Tetris字样。 curr()
方法将返回正在移动的当前作品,并将其绑定到JFrame
的左侧(x < 400)。现在由于某种原因,当我将它们添加到JFrame
时,我只能看到我添加的第二个,所以基本上它覆盖了另一个。我已经尝试了验证方法,它不起作用。摆动画问题?
如何同时显示它们?
下面的代码:
public Tetris()
{
// frame stuff
super("Tetris");
this.setSize(616,636);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_O…
// components
occ = new boolean [30][20];
rnd = new Random();
info = new TPanel();
for(int i=0;i<occ.length;i++)
for(int j=0; j< occ[i].length;j++)
occ [i][j] = false;
pieces.add(initPiece());
this.getContentPane().add(info);
this.getContentPane().add(curr());
this.getContentPane().validate();
repaint();
this.addKeyListener(this);
run();
}
为了更快得到更好的帮助,请发布[SSCCE](http://pscode.org/sscce.html)。 –