paint程序中的paintcomponent抛出空指针异常

时间:2016-09-21 13:30:32

标签: java paintcomponent repaint

我在JFrame上制作项目并在JFrame上添加JPanel。当我使用paintcomponents函数时,它正在抛出NullPointerException。我该怎么办?

    @Override
    public void paintComponents(Graphics g) {
        // TODO Auto-generated method stub

        super.paintComponents(g);
        if(OSC==null)
        {
            createOSC();
        }

        g.drawImage(OSC, 0, 0, null);

        if(dragging&&SHAPE_TOOLS.contains(currentTool))
        {
            g.setColor(currentColor);
            putCurrentShape(g);
        }

    }

0 个答案:

没有答案