Skip to content

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

Description

@wingrez

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions