Play-with-Algorithm-Visualization icon indicating copy to clipboard operation
Play-with-Algorithm-Visualization copied to clipboard

Circle-Animation project throws java.lang.NullPointerException.

Open wingrez opened this issue 6 years ago • 0 comments

定位:02-Java-Swing-Basics\Chapter-02-Completed-Codes\Circle-Animation\src\AlgoFrame.java -> AlgoCanvas -> paintComponent 问题:在一些运行中,抛出Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException 原因:paintComponent未经过render方法中的repaint方法自行调用,circles数组存在未定义的可能。 修复:一种简单的修复是在paintComponent中加入circles为null的检测。

wingrez avatar Apr 12 '20 09:04 wingrez