问题遇到的现象和发生背景
paint画不全数组的内容。
这个是数组
那些报错不用在意。
问题相关代码,请勿粘贴截图
public static int[][] MapList = {
{2,2,2,2,2,2,2,2,2,2},
{2,0,0,0,0,0,0,0,0,2},
{2,0,0,0,1,0,0,0,0,2},
{2,0,0,0,0,2,0,0,0,2},
{2,2,2,2,2,2,2,2,2,2}
};
@Override
public void paint(Graphics g) {
for (int i = 0;i < MapList.length;i++) {
for(int j = 0;j < MapList[i].length;j++) {
switch (j) {
case 2 -> {
Color c = g.getColor();
g.setColor(Color.WHITE);
g.drawString("墙",(i + 3) * 20,(j + 2) * 20);
g.setColor(c);
}
}
}
}
}
我想要达到的结果
画出来的内容可以和数组里摆的位置一样,并且我可以上下左右控制1的位置。