Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting a NullPointerException in my Swing Goose class
    primarykey
    data
    text
    <p>I think my <code>_holder</code> and/or <code>_gooseAction</code> is <code>null</code>.... Here are the relevant code/classes where <code>_holder</code> and <code>_gooseAction</code> are instantiated:</p> <h3>Goose.java</h3> <pre><code>public class Goose { //Goose class private ActionHolder _holder; private gooseAction _gooseAction; public Goose (JPanel container, GooseAction action, ActionHolder holder) { super(container); _holder = holder; _gooseAction = _holder.getAction(); _gooseAction = action; } public void react() { _gooseAction.stop(); _holder.getAction(); _gooseAction = _holder.getAction(); _gooseAction.setObjective(this); _gooseAction.start(); } </code></pre> <h3>ControlPanel.java</h3> <pre><code>public class ControlPanel { //top level class public ControlPanel() { super(); _holder = new ActionHolder(_moveAction); _drawingPanel = new DrawingPanel(_holder); _gooseAction = new GooseAction(); _doNothing = new StopBehavior(); _kingGoose = new FollowBehavior(_kingGoose); } private GooseAction _gooseAction; private ActionHolder _holder; public class ActionHolder { private GooseAction _GooseAction; public ActionHolder(GooseAction Action) { _gooseAction = Action; } public void setAction(GooseAction GooseAction) { _gooseAction = GooseAction; } public GooseAction getAction() { return _gooseAction.copy(); } } public class ActionButton extends JButton { public ActionButton(String string, boolean b, GooseAction action, ActionHolder holder) { super(string, b); _holder = holder; _gooseAction = action; } } private class ActionListener implements ChangeListener { public ActionListener(GooseAction action) { } public void stateChanged(ChangeEvent e) { _holder.setAction(_gooseAction); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload