Java 此令牌后预期的 VariableDeclaratorId
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19008491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VariableDeclaratorId expected after this token
提问by Aaron
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.
我正在尝试将图像添加到我的 GUI 中,但我有一个“在此令牌之后需要 VariableDeclaratorId”消息。我已经查找了如何解决它,但我无法弄清楚如何解决我的问题。
Here is the code:
这是代码:
frame.setIconImage= (
new ImageIcon(getClass().getResource("tictactoe.gif")).getImage());
I am getting the error on the setIconImage.
我在 setIconImage 上收到错误消息。
I'm doing this on eclipse.
我在日食上这样做。
采纳答案by NFE
You don't need assignment =
operator. This is used for assign variable value not for method.
您不需要赋值=
运算符。这用于分配变量值而不是方法。
Try
尝试
frame.setIconImage(
new ImageIcon(getClass().getResource("tictactoe.gif")).getImage());