2

I'm trying to add an image into my GUI, but im having a "VariableDeclaratorId expected after this token" message. I've looked up how to fix it, but I can't figure out how to fix my problem.

Here is the code:

frame.setIconImage= (
        new ImageIcon(getClass().getResource("tictactoe.gif")).getImage());

I am getting the error on the setIconImage.

I'm doing this on eclipse.

4

1 回答 1

5

您不需要赋值=运算符。这用于分配变量值而不是用于方法。

尝试

frame.setIconImage(
        new ImageIcon(getClass().getResource("tictactoe.gif")).getImage());
于 2013-09-25T15:07:21.583 回答