L
L
LaYof2016-07-23 09:20:51
Java
LaYof, 2016-07-23 09:20:51

How to solve the problem with "AWT-EventQueue-0" java.lang.NullPointerException?

ActionListener listen = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < fi.bo.length; i++) {
                if (fi.bo[i] == fi.obe.length) {
                    fi.shi = fi.shi + 1;


                }
            }
        }
    };

This ActionListener throws an AWT-EventQueue-0" java.lang.NullPointerException. Specifically, the line public void actionPerformed(ActionEvent e) . I don't understand the basics of this error. Please help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2016-07-23
@GavriKos

1) The code must be enclosed in the "code" tag - then it will be readable
2_ Most likely you have fi or bo == null. We are connected by a debugger and we look.

H
hightemp, 2017-04-30
@hightemp

Class EventQueue
In the same order as they are enqueued.
That is, if AWTEvent A is enqueued to the EventQueue before AWTEvent B then event B will not be dispatched before event A.
https://docs.oracle.com/javase/7/docs/api/java/awt...

try {
            EventQueue.invokeAndWait(new Runnable() {
              @Override
              public void run() {
                  new TApplication();
                    System.out.println("invokeAndWait");
                }
            });
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (Exception e) {
            Throwable cause = e.getCause();
            if (cause instanceof RuntimeException) {
                throw (RuntimeException) cause;
            } else {
                cause.printStackTrace();
            }
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question