board.java

来自「一个java的游戏程序」· Java 代码 · 共 34 行

JAVA
34
字号
import java.awt.*;import java.awt.event.*;/** * Creates a representation of the board for the games and keeps track * of the neighbouring fields and if any token occupy them, it tells * the field View and Field Controller where the tokens are on the * board, so they can depict it */class Board     extends Panel{    private Grid _grid;    public Board(int width, int height, FieldFactory factory)    {	_grid = new Grid(width, height, factory);	setLayout(new GridLayout(width,height));	for(int v = 0; v < height; v++)	    for(int h = 0; h < width; h++)		{		    Component view;		    view = factory.createView((Field)_grid.getCell(h,v));		    add(view);		}    }    public void clear()    {	_grid.clear();    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?