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);
System.out.println("ADD");
} else if("delete".equals(ear.getActionCommand() )){
System.out.println("DELETE");
}
}
Why doesn't this work? Any suggestions would be appreciated!