日期:2014-05-20  浏览次数:20778 次

求代码
我想在pause的位置在就加一段话,就是让它在执行的时候显示一个字符串,应该怎么加代码? 
public void run() {
  while (true) {
  try {
  Thread.sleep(10);
  } catch (Exception ex) {

  }
  repaint();
  if(pause){
  return;
  }
  if (temp1 % 2 == 0) {
  x++;
  }
  if (temp1 % 2 != 0) {
  x--;
  }
  if (x == 230) {
  temp1++;
  }
  if (x == 0) {
  temp1 = 0;
  }

  if (temp2 % 2 == 0) {
  y++;
  }
  if (temp2 % 2 != 0) {
  y--;
  }
  if (y == 290) {
  temp2++;
  }
  if (y == 0) {
  temp2 = 0;
  }
  if (y == 290) {
  if ((x < nX) || (x > nX + 30)) {
  pause = true;
  }
  }
   
  }
  }

------解决方案--------------------
if (y == 290) {
if ((x < nX) || (x > nX + 30)) {
pause = true;
Graphic g = getGraphic(); //其实应该把这里的代码写到paint方法里
g.drawString("O", x, y);
}