Alvin Pulido
Alvin Pulido

Reputation: 49

GUI doesn't appear Java

Hi I am creating a program and I encountered an error when running it. It says:

    Exception in thread "main" java.lang.NullPointerException
            at java.awt.Container.addImpl(Container.java:1045)
            at java.awt.Container.add(Container.java:365)
            at javax.swing.JPopupMenu.add(JPopupMenu.java:264)
            at javax.swing.JMenu.add(JMenu.java:562)
            at truthtable.GUI.getCreatedMenuBar(GUI.java:587)
            at truthtable.GUI.<init>(GUI.java:208)
            at truthtable.Application.<init>(Application.java:10)
            at truthtable.Application.main(Application.java:18)
    Java Result: 1

My class Application.java:

  package truthtable;
    public class Application {

        public Application() {
            new GUI(null);
        }

        public static void main(final String[] args) {
            new Application();
        }
    }

What does this mean? And when i tried to edit the code in that error, it is readonly.

This is my code for gui constructor :

 public GUI(final ApplicationStarter appStarter) {
        super();

        this.applicationStarter = appStarter;
        outputMode = TruthValue.TRUE_FALSE;
        computationMethod = COMPLETE_METHOD;
        hasFullPermission = getHasFullPermission();
        smallTableLimit = 256;
        maxStatementLength = 256;
        maxRowsInTextTable = 1024;

      int arraySize=3;

        buttonStates = new boolean[4];
        final GridBagConstraints gbc = new GridBagConstraints();
        defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
        waitCursor = new Cursor(Cursor.WAIT_CURSOR);

        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addComponentListener(new ComponentAdapter() {
            public void componentResized(final ComponentEvent e) {
                int width = getWidth(),
                    height = getHeight();

                final int minHeight=50;
                final int minWidth=20;
                if (width < minWidth)
                    width = minWidth;
                if (height < minHeight)
                    height = minHeight;
                setSize(width, height);
            }

Upvotes: 0

Views: 881

Answers (2)

GreekOphion
GreekOphion

Reputation: 388

I believe you are running the wrong program. You need a GUI constructor to go with it.

Upvotes: 1

duffymo
duffymo

Reputation: 308918

It's a problem with the GUI constructor that you don't show code for. It looks like passing null will be a problem. Is it expecting a non-null value? If yes, figure out how to provide one.

Upvotes: 1

Related Questions