Wednesday, August 18, 2004

Of ActionListeners and Popup menus

An example of how to use ActionListeners.
-------------------------------------------

class LoadAction extends AbstractAction {
LoadAction(){
super("Load"); //this is the menu item name in a popup

}

public void actionPerformed(ActionEvent e){
//do what you want to here
}

---------------
JPopupMenu popup = new JPopupMenu();
popup.add(new LoadAction());
---------------

You can also call the Action explicitly by

new LoadAction().actionPerformed(null);

-----

If you need access to members of the parent class pass them to the LoadAction constructor. when you create it.
--------
edu.upmc.opi.spin.client.SpinDataStoreTreeViewer



No comments: