为什么我在下面的 switch 语句中出现“}”错误。我没有看到任何语法错误。我在编译代码时没有收到错误。Eclipse 在下面的指定位置指示错误。
放}后我得到这个错误
- The static field KeyEvent.VK_XXXX should be accessed in a
static way
- case expressions must be constant expressions
switch(event.getKeyCode())
{
case event.VK_BACK_SLASH:
backColor=but[27].getBackground();
break;
case event.VK_RIGHT:
for(int i=0;i<but.length;i++)
{
if(" > ".equals(but[i].getText()))
{
backColor=but[i].getBackground();
break;
}
}
break; // error here
}
当我按下键时,出现以下错误
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
Syntax error, insert "}" to complete SwitchBlock
at Keyboard$HandlerClass.keyPressed(Keyboard.java:242) // this is break statement
at java.awt.Component.processKeyEvent(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
问候