Over a million developers have joined DZone.

Changing a Default Action's Icon in NetBeans RCP

DZone's Guide to

Changing a Default Action's Icon in NetBeans RCP

· Java Zone ·
Free Resource

How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.

If you are developing an application using NetBeans RCP probably you are using default actions like Delete, Cut or Save that uses its own icons. This post talks about two techniques so change the default icons associated to an existent action.

The first method to change the default icon is through the branding directory in your module suite. To allow this, you need to know in which Java package is stored the icon resource used by the action you want to change its icon. A good way to know this is downloading the NetBeans platform (or other module) source code, looking for the action code and get the icon's resource path.

For example, the Cut and Delete actions are in the package org.openide.action. If you want to override it with your own icons all you need to is is to create, in your module suite branding directory, a folder called org-openide-action.jar, create a subfolder hierarchy representing the package structure and put your own icons with the same name the action code uses.

The second method implies to create a new action that wraps the target action you want to change its icons.
The below present a little class WrapperCutAction that wraps the NetBeans CutAction. The idea is pretty simple, the wrapper action can have any desired icon and when it is executed only you need to do is redirect the event to the target action.

package yourpackage;

import java.awt.event.ActionEvent;
import org.openide.actions.CutAction;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallbackSystemAction;

public final class WrapperCutAction extends CallbackSystemAction {

public static final String ICON_PATH = "org/balloon/ui/icons/edit-cut.png";
// Wrap the target action
private CutAction ca = new CutAction();

public String getName() {
return NbBundle.getMessage(WrapperCutAction.class, "CTL_WrapperCutAction");

protected String iconResource() {
return ICON_PATH;

public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;

protected boolean asynchronous() {
return false;

// Wrap the target methods
public void actionPerformed(ActionEvent e) {

public Object getActionMapKey() {
return ca.getActionMapKey();

How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}