当前位置: 技术问答>java相关
我在applet使用鼠标事件的时侯总会出现如下异常,编译通过。
来源: 互联网 发布时间:2015-01-21
本文导语: E:javachess>javac chess.java 注意: chess.java 使用或覆盖一个不鼓励使用的API。 注意: 使用-deprecation重新编译,以得到详细信息。 运行后: java.lang.ArrayIndexOutOfBoundsException at chess.isMove(chess.java:439) ...
E:javachess>javac chess.java
注意:
chess.java 使用或覆盖一个不鼓励使用的API。
注意:
使用-deprecation重新编译,以得到详细信息。
运行后:
java.lang.ArrayIndexOutOfBoundsException
at chess.isMove(chess.java:439)
at chess.mouseUp(chess.java:94)
at java.awt.Component.handleEvent(Component.java:3895)
at java.awt.Component.postEvent(Component.java:2790)
at java.awt.Component.dispatchEventImpl(Component.java:2607)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.jav
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException
at chess.mouseDrag(chess.java:134)
at java.awt.Component.handleEvent(Component.java:3892)
at java.awt.Component.postEvent(Component.java:2790)
at java.awt.Component.dispatchEventImpl(Component.java:2607)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.jav
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
此异常从哪里来的?我需要如何捕获他?
注意:
chess.java 使用或覆盖一个不鼓励使用的API。
注意:
使用-deprecation重新编译,以得到详细信息。
运行后:
java.lang.ArrayIndexOutOfBoundsException
at chess.isMove(chess.java:439)
at chess.mouseUp(chess.java:94)
at java.awt.Component.handleEvent(Component.java:3895)
at java.awt.Component.postEvent(Component.java:2790)
at java.awt.Component.dispatchEventImpl(Component.java:2607)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.jav
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException
at chess.mouseDrag(chess.java:134)
at java.awt.Component.handleEvent(Component.java:3892)
at java.awt.Component.postEvent(Component.java:2790)
at java.awt.Component.dispatchEventImpl(Component.java:2607)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.jav
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
此异常从哪里来的?我需要如何捕获他?
|
数组越界了。
|
javac chess.java -deprecation得到deprecated的类
异常:
at chess.isMove(chess.java:439)----439行
at chess.mouseUp(chess.java:94)----94行
at chess.mouseDrag(chess.java:134)----134行
捕获:
try{
...
}catch(ArrayIndexOutOfBoundsException e){
...
}
That's all!
异常:
at chess.isMove(chess.java:439)----439行
at chess.mouseUp(chess.java:94)----94行
at chess.mouseDrag(chess.java:134)----134行
捕获:
try{
...
}catch(ArrayIndexOutOfBoundsException e){
...
}
That's all!
|
数组越界
try
{
}
catch(ArrayIndexOutOfBoundsException e)
{
}
try
{
}
catch(ArrayIndexOutOfBoundsException e)
{
}