Adding A Toolbar Button

From OpenJUMP Wiki
Jump to navigation Jump to search

Here's an example of adding a plugin to the toolbar as a button:

workbenchFrame.getToolBar().addPlugIn(outputWindowPlugIn.getIcon(), outputWindowPlugIn, new MultiEnableCheck(), workbenchContext)

Another way to do it is to use

WorkbenchToolBar#add(AbstractButton button, String tooltip, Icon icon, ActionListener actionListener, EnableCheck enableCheck)

Still another way is to use WorkbenchToolBar#add(Component)


[31. Aug 2006]

Hei,

to add a button you need:

  • to specify an icon for you plugin => xxxPlugIn.getIcon();
  • to add it to the toolbar. For Jump own plugins this is done in JumpConfiguration.configureToolBar(final WorkbenchContext workbenchContext, EnableCheckFactory checkFactory)

e.g.

WorkbenchFrame frame = workbenchContext.getWorkbench().getFrame();
    frame.getToolBar().addPlugIn(zoomToSelectedItemsPlugIn.getIcon(),
               zoomToSelectedItemsPlugIn,
               ZoomToSelectedItemsPlugIn.createEnableCheck(workbenchContext),
               workbenchContext);


If you have access to the OpenJUMP SVN repository you can see an example in the NewTaskPlugIn.java in package com.vividsolutions.jump.workbench.ui.plugin; another example .. if you use original JUMP .. may be look on ZoomToSelectedItemsPlugIn.java in package workbench.ui.zoom

stefan