Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circle-Animation project throws java.lang.NullPointerException. #1

Open
wingrez opened this issue Apr 12, 2020 · 0 comments
Open

Circle-Animation project throws java.lang.NullPointerException. #1

wingrez opened this issue Apr 12, 2020 · 0 comments

Comments

@wingrez
Copy link

wingrez commented Apr 12, 2020

定位: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的检测。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant