Пример #1
0
 public void display() {
   for (int i = 0; i < mat.length; i++) {
     for (int j = 0; j < mat[i].length; j++) {
       System.out.print(mat[i][j] + " ");
       // changeCell(i, j, Color.white, mat[i][j], Color.black, 50);
       F.cellBack(i, j, Color.black, Color.white);
       // F.add(new JRectangle(dx*j, dy*i, dx, dy, Color.black, Color.white), timing);
       F.cellContent(i, j, mat[i][j], Color.black);
       // F.add(new JString(dx*j+5, dy*i+25, mat[i][j], Color.black), timing);
     }
     System.out.println();
     F.cellContent(i, 17, Integer.toString(i), Color.white);
   }
   for (int j = 0; j < mat[0].length; j++) {
     F.cellContent(17, j, Integer.toString(j), Color.white);
   }
 }
Пример #2
0
  /**
   * public void changeCell(Integer row, Integer col, Color background, String symbol, Color
   * foreground, Integer time){ F.add(new JRectangle(dx*col, dy*row, dx, dy, Color.black,
   * background), time); F.add(new JString(dx*col+5, dy*row+25, symbol, foreground), time); }
   */
  public void displayWord(int row, int col, String word, Direction d, Color color) {

    // F.cellBack(row, col, Color.black, color);
    // F.cellContent(row, col, mat[row][col], Color.black);
    for (int index = 0; index < word.length(); index++) {
      F.cellBack(row, col, Color.black, color);
      F.cellContent(row, col, mat[row][col], Color.black);
      row = row + d.deltaRow;
      col = col + d.deltaCol;
    }

    try {
      Thread.sleep(2000);
    } catch (Exception e) {
    }

    for (int index = 0; index < word.length(); index++) {
      row = row - d.deltaRow;
      col = col - d.deltaCol;
      F.cellBack(row, col, Color.black, Color.white);
      F.cellContent(row, col, mat[row][col], Color.black);
    }
  }