...
Code Block | ||
---|---|---|
| ||
@ActionRegistration(displayName = "Compare Bands", lazy = false) @NbBundle.Messages({"CTL_CompareBandActionName=Compare Bands"}) public class CompareBandAction extends AbstractAction implements ContextAwareAction, LookupListener { private final Lookup lkp; private final Lookup.Result<Band> result; public CompareBandAction() { this(Utilities.actionsGlobalContext()); } public CompareBandAction(Lookup lkp) { super(Bundle.CTL_CompareBandActionName()); this.lkp = lkp; result = lkp.lookupResult(Band.class); result.addLookupListener(WeakListeners.create(LookupListener.class, this, result)); setEnabled(false); } @Override public Action createContextAwareInstance(Lookup lkp) { return new CompareBandAction(lkp); } @Override public void actionPerformed(ActionEvent e) { // Do the action stuff } @Override public void resultChanged(LookupEvent le) { setEnabled(result.allInstances().size() >= 2); } } |
Note | ||
---|---|---|
| ||
When using Bundle properties in an action with the The Annotation @NbBundle.Messages only works if the package where the action is implemented is not yet defined in an other module. Having the package |
...