You need to implement the ActionListener interface, and deal with each action accordingly. See How to Write an Action Listener for more information