Posts Tagged ‘actions’

Adding special chars to NetBeans action name

Tuesday, June 10th, 2008

This one I posted in NetBeans mailing lists. If you want to show a special char (like a slash - “/”) in the action display name (i.e. in the way your user will see it), the right way is to pass it to the AbstractAction constructor (just like the templates of NetBeans):

public class SpecialCopyPasteAction extends AbstractAction {

  public SpecialCopyPasteAction() {
    super(NbBundle.getMessage(SpecialCopyPasteAction.class,
        "CTL_ SpecialCopyPasteAction"));
  }

  public void actionPerformed(ActionEvent evt) {
    // TODO: Implement it
  }
}

And, in Bundle.properties:

CTL_SpecialCopyPasteAction=Special Copy/Paste

Remember that the action name in layer.xml is mapped to a system file name. You cannot put a “/” on file names, even on Windows. This is one of the reasons NB filesystem has the localization feature.