コード例 #1
0
ファイル: ArrayPanel.java プロジェクト: geonz/multiplyGrids
  public ArrayPanel(int x, int y) {
    numColumns = x;
    numRows = y;
    setPreferredSize(new Dimension(WIDTH, HEIGHT));
    squareGrid =
        new Square[numColumns][numRows]; // this is making the array iwth the little squares

    // let us construct a grid of the squares
    for (int i = 0; i < numColumns; i++)
      for (int j = 0; j < numRows; j++) // this is how to do the 2D array.  Which is cool.
      {
        oneSquare = new Square(i, j);
        oneSquare.setInGroup(false); // this starts it out as "just here."
        squareGrid[i][j] = oneSquare;
      } // now our array is filled with oneSquares.
  }