不完全确定您收到的错误消息。以下示例
EnumIssue.java
工作正常:
public class EnumIssue {
enum Job
{
SPAWN, KING, NORM
}
enum myColor
{
RED, BLACK
}
public static void main(String[] args) {
Job j = Job.SPAWN;
myColor c = myColor.BLACK;
System.out.println(j);
System.out.println(c);
}
}
输出:
SPAWN
BLACK
在提供了相关的完整代码后添加:
在类中移动变量声明
Tile
。更新的代码段如下所示:
:
:
import javax.swing.JPanel;
enum Job{SPAWN, KING, NORM};
enum myColor{RED, BLACK};
//This is where current variable declarations are. Move them inside class.
public class Tile
{
//This is where variable declarations are moved to.
int tileRow;
int tileCol;
Job job;
myColor side;
JButton button;
Checker piece;
Color color;
public Tile(int posRow, int posCol, JPanel panel, ActionListener listener)
{
int tileRow = posRow;
:
: