class MyControl{ String status = "Move"; //initialize a variable status Button bmove; //three buttons Button brotate; Button bscale; MyControl(){ bmove = new Button("Move"); //create the buttons brotate = new Button("Rotate"); bscale = new Button("Scale"); add(bmove); //add them to the screen add(brotate); add(bscale); bmove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { status = bmove.getLabel(); } } ); brotate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { status = brotate.getLabel(); } } ); bscale.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { status = bscale.getLabel(); } } ); } } MyControl control = new MyControl();