public CloseButton(Environment environment) 
    {
        super();
        setDefaults();
        env = environment;
        env.addChangeListener(new ChangeListener() 
            {
                public void stateChanged(ChangeEvent e) 
                { 
                    checkEnabled(); 
                }
            });
        addActionListener(new ActionListener()
            {

                public void actionPerformed(ActionEvent e) 
                {
                    boolean editor = false;
                    Automaton inside = null;
                    State block = null;
                    if(env.getActive() instanceof EditBlockPane)
                    {
                        editor = true;
                        EditBlockPane blockEditor = (EditBlockPane) env.getActive();
                        inside = blockEditor.getAutomaton();
                        block = blockEditor.getBlock();
                    }
                    env.remove(env.getActive());
                    if(editor) 
                    {
                        EditorPane higherEditor = (EditorPane) env.getActive();
                        assert(higherEditor.getAutomaton() instanceof TuringMachine);
                        TuringMachine higher = (TuringMachine) higherEditor.getAutomaton();
                        //MERLIN MERLIN MERLIN MERLIN MERLIN//

//                        higher.replaceBlock(block, inside); this shouldn't be necessary if we are not making a clone, but editing the real thing.
                    }
                }
            });
        checkEnabled();
    }