Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 1.15 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. NetBeans Platform: Action disabled, but shortcut active
  2. package com.demo.toolbar;
  3.  
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import org.openide.awt.ActionRegistration;
  7. import org.openide.awt.ActionReference;
  8. import org.openide.awt.ActionReferences;
  9. import org.openide.awt.ActionID;
  10. import org.openide.util.NbBundle.Messages;
  11.  
  12. @ActionID(category = "Edit",
  13. id = "com.demo.toolbar.AddAction")
  14. @ActionRegistration(iconBase = "com/demo/toolbar/icons/add.png",
  15. displayName = "#CTL_AddAction")
  16. @ActionReferences({
  17.     @ActionReference(path = "Toolbars/AddEditDelete", position = 1),
  18.     @ActionReference(path = "Shortcuts", name = "D-A")
  19. })
  20. @Messages("CTL_AddAction=Add")
  21. public final class AddAction implements ActionListener {
  22.  
  23.     public void actionPerformed(ActionEvent e) {
  24.         //code here
  25.     }
  26. }
  27.        
  28. List<Component> c = new ArrayList<Component>();
  29.         c.addAll(Arrays.asList(ToolbarPool.getDefault().findToolbar("AddEditDelete").getComponents()));
  30. if (mode.equals("add")) {
  31.     for (Component component : c) {
  32.         component.setEnabled(false);
  33.         }
  34.         c.get(13).setEnabled(true);
  35.         c.get(14).setEnabled(true);
  36. }