if (onoffButton != null) { onoffButton.removeActionListener(this); } if (paletteButton != null) { paletteButton.removeActionListener(this); } layerName = null; this.layer = null; this.layerHandler = null; this.removeAll();
cleanup();
    public void cleanup() {        if (layer != null) {            this.layer.removeComponentListener(this);        }        if (onoffButton != null) {            onoffButton.removeActionListener(this);        }        if (paletteButton != null) {            paletteButton.removeActionListener(this);        }        layerName = null;        this.layer = null;        this.layerHandler = null;        this.removeAll();    }