私は単純なチェッカーボード プログラムを使用していますが、問題なく動作しますが、非常に小さいです。acm.graphics.setsize メソッドを使用してウィンドウのサイズを変更しようとしましたが、グラフィック オブジェクトを配置するまでサイズが変更されません。プログラムが正しく動作するように、プログラムへの変更を「フラッシュ」するために何かをする必要がありますか?
ありがとう
/* File CheckerBoard.java
* ----------------------
* This program creates a checkerboard
*/
import acm.graphics.*;
import acm.program.*;
/* This class draws a checkerboard on the graphics window.
* The size of the checkerboard is determined by the
* constants NROWS and NCOLUMNS, and the checkerboard fills
* the verticle space available.
*/
public class CheckerBoard extends GraphicsProgram
{
/* Number of rows */
private static final int NROWS = 8;
/* Number of columns */
private static final int NCOLUMNS = 8;
// Window Size
private static final int height = 1024;
private static final int width = 1024;
/* Runs the program */
public void run()
{
setSize(height,width);
int sqSize = getHeight() / NROWS;
for (int i = 0; i < NROWS; i++)
{
for (int j = 0; j < NCOLUMNS; j++)
{
int x = j * sqSize;
int y = i * sqSize;
GRect sq = new GRect (x, y, sqSize, sqSize);
sq.setFilled(((i + j) % 2) != 0);
add (sq);
}
}
}
}