Hi, im trying to use an actionlistener attached to a button to add a component to a frame I have created. The actual button should add to the frame a circle with some text placed in it which I have already created, it works fine so there's no problems there.

When I do this in my main method (i.e startGUI() )

static JTree j1 = new JTree();
centerframe.add(j1, BorderLayout.CENTER);

it is displayed fine but when i use it in the following context it does nothing (except display the output message i use to check whether the actions are performing when the buttons are clicked:

public void actionPerformed(ActionEvent ear) 
		 if("addition".equals(ear.getActionCommand() )  ){
			 centerframe.add(j1, BorderLayout.CENTER);
		 } else if("delete".equals(ear.getActionCommand() )){

Why doesn't this work? Any suggestions would be appreciated!

Yeah so I've solved this little problem too. Theres a-lot of code involved so I won't display it all. I'll leave the part that draws the actually components out.

JButton generate = new JButton("Generate Tree");
		generate.addActionListener(new ActionListener()
			public void actionPerformed(ActionEvent e)
				Shapes widget;
				widget = new Shapes();
				printtoFile("\nOrder: "+setMessage());
				printtoFile("Size of Tree: "+Size());
				printtoFile("Tree Height: "+getTreeHeight());
				printtoFile("Root node: "+returnRoot()+"\n");

Hope this helps :D