0

I'm very helpless at the moment. I have a error while running this program:

import java.awt.*;
import javax.swing.*;

public class Puzzle extends JFrame {
    static Puzzle m_fenster;
    private JPanel ahead, center, buttom;
    private JButton ol, om, or, ml, mm, mr, ul, um, ur;
    Puzzle(String titel)
    {
        super(titel);
        setLayout(new FlowLayout());
        ahead = new JPanel();
        center = new JPanel();
        buttom = new JPanel();

        ol = new JButton();
        om = new JButton();
        ol = new JButton();
        ml = new JButton();
        mm = new JButton();
        mr = new JButton();
        ul = new JButton();
        um = new JButton();
        ur = new JButton();

        ol.setIcon(new ImageIcon("aheadLeft.png"));
        om.setIcon(new ImageIcon("aheadCenter.png"));
        or.setIcon(new ImageIcon("aheadRight.png"));
        ml.setIcon(new ImageIcon("centerLeft.png"));
        mm.setIcon(new ImageIcon("centerCenter.png"));
        mr.setIcon(new ImageIcon("centerRight.png"));
        ul.setIcon(new ImageIcon("bottomLeft.png"));
        um.setIcon(new ImageIcon("bottomCenter.png"));
        ur.setIcon(new ImageIcon("bottomRight.png"));

        ahead.add(ol);
        ahead.add(om);
        ahead.add(or);
        add(ahead);

        center.add(ml);
        center.add(mm);
        center.add(mr);
        add(center);

        bottom.add(ul);
        bottom.add(um);
        bottom.add(ur);
        add(bottom);

    }
    public static void main(String[] args) {
        m_window = new Puzzle("Puzzle");
        m_window.setSize(800,700);
        m_window.pack();
        m_window.setVisible(true);
    }

}

I'm sure the files exist in the folder. The code can be compiled without problems, but when running the error

Exception in thread "main" java.lang.NullPointerException
at Puzzle.<init>(Puzzle.java:30)
at Puzzle.main(Puzzle.java:55)

It's possible it's a very simple error. Any idea?

PEAR
  • 685
  • 3
  • 10
  • 20

0 Answers0