当前位置: 首页>>代码示例>>Java>>正文


Java AbstractAction.putValue方法代码示例

本文整理汇总了Java中javax.swing.AbstractAction.putValue方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractAction.putValue方法的具体用法?Java AbstractAction.putValue怎么用?Java AbstractAction.putValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.AbstractAction的用法示例。


在下文中一共展示了AbstractAction.putValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createContextAwareInstance

import javax.swing.AbstractAction; //导入方法依赖的package包/类
@Override
public Action createContextAwareInstance(final Lookup actionContext) {
    if (actionContext.lookup(TargetLister.Target.class) != null) { //#220590
        final Target target = actionContext.lookup(TargetLister.Target.class);
        AbstractAction a = new AbstractAction(getName()) {
                          @Override
                          public void actionPerformed(ActionEvent e) {
                              try {
                                  new TargetExecutor(target.getOriginatingScript(), new String[]{target.getName()}).execute();
                              } catch (IOException ioe) {
                                  AntModule.err.notify(ioe);
                              }
                          }
                      };
        
        a.putValue(ACCELERATOR_KEY, this.getValue(ACCELERATOR_KEY));            
        return a;
    } else {
        return new ContextAction(actionContext);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:RunTargetsAction.java

示例2: testCheckPrioritiesOfIcons

import javax.swing.AbstractAction; //导入方法依赖的package包/类
public void testCheckPrioritiesOfIcons() {
    AbstractAction aa = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };
    Icon icon = ImageUtilities.loadImageIcon("org/openide/awt/TestIcon_big.png", true);
    aa.putValue(Action.SMALL_ICON, icon);
    aa.putValue("iconBase", "org/openide/awt/data/testIcon.gif");
    
    JButton b = new JButton();
    Actions.connect(b, aa);
    
    JMenuItem m = new JMenuItem();
    Actions.connect(m, aa, false);
    
    
    assertSame("Using the same icon (small" + icon, b.getIcon(), m.getIcon());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ActionsTest.java

示例3: testCheckPrioritiesOfIconsWithStringSmallIcon

import javax.swing.AbstractAction; //导入方法依赖的package包/类
public void testCheckPrioritiesOfIconsWithStringSmallIcon() {
    AbstractAction aa = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };
    Object icon = "org/openide/awt/TestIcon_big.png";
    aa.putValue(Action.SMALL_ICON, icon);
    aa.putValue("iconBase", "org/openide/awt/data/testIcon.gif");
    
    JButton b = new JButton();
    Actions.connect(b, aa);
    
    JMenuItem m = new JMenuItem();
    Actions.connect(m, aa, false);
    
    
    assertSame("Using the same icon (small" + icon, b.getIcon(), m.getIcon());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ActionsTest.java

示例4: getContextMenuActions

import javax.swing.AbstractAction; //导入方法依赖的package包/类
@Override
public ActionMenu getContextMenuActions(Program program) {        
    AbstractAction action = new AbstractAction() {
        
        @Override
        public void actionPerformed(ActionEvent evt) {
            sendAnTSR(program);
        }
    };

    // Der Aktion einen Namen geben. Dieser Name wird dann im Kontextmenü gezeigt
    String name = mLocalizer.msg("popupCaption","Capture with TvStreamRecord");
    action.putValue(Action.NAME, name);        

    // Der Aktion ein Icon geben. Dieses Icon wird mit dem Namen im Kontextmenü gezeigt
    // Das Icon sollte 16x16 Pixel groß sein
    ImageIcon icon = createImageIcon("img/tvstreamrecord.png");
    action.putValue(Action.SMALL_ICON, icon);

    // Das Aktions-Menü erzeugen und zurückgeben
    return new ActionMenu(action); 
}
 
开发者ID:Pavion,项目名称:TsrPlugin,代码行数:23,代码来源:TsrPlugin.java

示例5: createAction

import javax.swing.AbstractAction; //导入方法依赖的package包/类
public Action createAction(final String name, final String label,
                           final String describe, final Icon icon, final KeyStroke stroke) {
    final AbstractAction action = new AbstractAction(label, icon) {

        public void actionPerformed(ActionEvent e) {
            MainFrame.this.actionPerformed(e);
        }

    };
    actions.put(name, action);
    action.putValue(Action.ACTION_COMMAND_KEY, name);
    if (describe != null)
        action.putValue(Action.SHORT_DESCRIPTION, describe);
    if (stroke != null)
        action.putValue(Action.ACCELERATOR_KEY, stroke);

    return action;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:19,代码来源:MainFrame.java

示例6: bind

import javax.swing.AbstractAction; //导入方法依赖的package包/类
/**
 * 
 * @param name
 * @param action
 * @return a new Action bound to the specified string name and icon
 */
@SuppressWarnings("serial")
public Action bind(String name, final Action action, String iconUrl)
{
	AbstractAction newAction = new AbstractAction(name, (iconUrl != null) ? new ImageIcon(
			BasicGraphEditor.class.getResource(iconUrl)) : null)
	{
		public void actionPerformed(ActionEvent e)
		{
			action.actionPerformed(new ActionEvent(getGraphComponent(), e
					.getID(), e.getActionCommand()));
		}
	};
	
	newAction.putValue(Action.SHORT_DESCRIPTION, action.getValue(Action.SHORT_DESCRIPTION));
	
	return newAction;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:BasicGraphEditor.java

示例7: canCloseElement

import javax.swing.AbstractAction; //导入方法依赖的package包/类
final CloseOperationState canCloseElement(TopComponent tc) {
    // if this is not the last cloned java editor component, closing is OK
    if (!isLastView(tc)) {
        return CloseOperationState.STATE_OK;
    }

    if (!isModified()) {
        return CloseOperationState.STATE_OK;
    }

    AbstractAction save = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                saveDocument();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    };
    save.putValue(Action.LONG_DESCRIPTION, NbBundle.getMessage(BIEditorSupport.class, "MSG_MODIFIED", getDataObject().getPrimaryFile().getNameExt()));

    // return a placeholder state - to be sure our CloseHandler is called
    return MultiViewFactory.createUnsafeCloseState(
            "ID_BEANINFO_CLOSING", // NOI18N
            save,
            MultiViewFactory.NOOP_CLOSE_ACTION);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:BIEditorSupport.java

示例8: canCloseElement

import javax.swing.AbstractAction; //导入方法依赖的package包/类
@Messages({
    "MSG_SaveModified=File {0} is modified. Save?"
})
@Override
public CloseOperationState canCloseElement() {
    final CloneableEditorSupport sup = getLookup().lookup(CloneableEditorSupport.class);
    Enumeration en = getReference().getComponents();
    if (en.hasMoreElements()) {
        en.nextElement();
        if (en.hasMoreElements()) {
            // at least two is OK
            return CloseOperationState.STATE_OK;
        }
    }
    
    PropertiesDataObject dataObject = getDataObject();
    if (dataObject.isModified()) {
        AbstractAction save = new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    sup.saveDocument();
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        };
        save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_SaveModified(FileUtil.getFileDisplayName(dataObject.getPrimaryFile())));
        return MultiViewFactory.createUnsafeCloseState("editor", save, null);
    } 
    return CloseOperationState.STATE_OK;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:PropertiesEditorSupport.java

示例9: canCloseElement

import javax.swing.AbstractAction; //导入方法依赖的package包/类
@Messages({
    "MSG_MODIFIED=File {0} is modified. Save?"
})
final CloseOperationState canCloseElement(TopComponent tc) {
    // if this is not the last cloned java editor component, closing is OK
    if (!FormEditorSupport.isLastView(tc)) {
        return CloseOperationState.STATE_OK;
    }

    if (!isModified()) {
        return CloseOperationState.STATE_OK;
    }
    
    AbstractAction save = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                saveDocument();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    };
    save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_MODIFIED(
        getDataObject().getPrimaryFile().getNameExt()
    ));

    // return a placeholder state - to be sure our CloseHandler is called
    return MultiViewFactory.createUnsafeCloseState(
            "ID_FORM_CLOSING", // NOI18N
            save,
            MultiViewFactory.NOOP_CLOSE_ACTION);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:FormEditorSupport.java

示例10: resetTabIcons

import javax.swing.AbstractAction; //导入方法依赖的package包/类
@Override
public void resetTabIcons() {
	// configure attach button
	attachAction = new AbstractAction("Attach") {

		private static final long serialVersionUID = 390635147992456838L;

		@Override
		public void actionPerformed(ActionEvent e) {
			desktop.setFloating(getDockable(), false);
		}
	};
	attachSmartIcon = new SmartIconJButton(attachAction);
	attachAction.putValue(Action.SHORT_DESCRIPTION, UIManager.get("DockViewTitleBar.attachButtonText"));
	attachSmartIcon.setIcon(UIManager.getIcon("DockViewTitleBar.attach"));
	attachSmartIcon.setPressedIcon(UIManager.getIcon("DockViewTitleBar.attach.pressed"));
	attachSmartIcon.setRolloverIcon(UIManager.getIcon("DockViewTitleBar.attach.rollover"));

	ArrayList<SmartIconJButton> icons = new ArrayList<SmartIconJButton>();
	DockKey dockKey = getDockable().getDockKey();
	if (dockKey.isCloseEnabled()) {
		icons.add(closeSmartIcon);
	}
	if (dockKey.isFloatEnabled()) {
		icons.add(attachSmartIcon);
	}
	if (icons.size() > 0) {
		SmartIconJButton[] iconsArray = icons.toArray(new SmartIconJButton[0]);
		smartIcon = new JTabbedPaneSmartIcon(dockKey.getIcon(), dockKey.getName(), null, null, true, iconsArray);
		smartIcon.setIconForTabbedPane(tabHeader);
		tabHeader.addTab("", smartIcon, getDockable().getComponent());
	} else {
		tabHeader.addTab(dockKey.getName(), dockKey.getIcon(), getDockable().getComponent());
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:37,代码来源:DetachedDockViewAsTab.java

示例11: HelpFile

import javax.swing.AbstractAction; //导入方法依赖的package包/类
public HelpFile(String title, URL contents) {
  this.title = title;
  this.contents = contents;
  setConfigureName(title);

  launch = new AbstractAction() {
    private static final long serialVersionUID = 1L;

    public void actionPerformed(ActionEvent e) {
      showWindow();
    }
  };

  launch.putValue(Action.NAME, getConfigureName());
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:16,代码来源:HelpFile.java

示例12: setActionButton

import javax.swing.AbstractAction; //导入方法依赖的package包/类
public void setActionButton(String button, AbstractAction a) {
	for (JButton element : btnList) {
		try {
			if (element.getText().equals(button)) {
				a.putValue(Action.NAME, button);
				element.setAction(a);
				break;
			}
		} catch (ClassCastException e) {
			System.err.println("DEBUG: Casting not allowed");
		}
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:14,代码来源:JWatWizard.java

示例13: createAction

import javax.swing.AbstractAction; //导入方法依赖的package包/类
private AbstractAction createAction(final String name, final String text, final Icon icon) {
    final AbstractAction action = new AbstractAction(name, icon) {

        public void actionPerformed(ActionEvent e) {
            WebPanel.this.actionPerformed(e);
        }

    };
    action.putValue(Action.LONG_DESCRIPTION, text);
    action.putValue(Action.SHORT_DESCRIPTION, text);
    action.putValue(Action.DEFAULT, text);
    actions.add(action);
    return action;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:15,代码来源:WebPanel.java

示例14: bind

import javax.swing.AbstractAction; //导入方法依赖的package包/类
/**
 * 
 * @param name
 * @param action
 * @return a new Action bound to the specified string name and icon
 */
@SuppressWarnings("serial")
public Action bind(String name, final Action action, String iconUrl) {
  AbstractAction newAction = new AbstractAction(name,
      (iconUrl != null) ? new ImageIcon(BasicGraphEditor.class.getResource(iconUrl)) : null) {
    public void actionPerformed(ActionEvent e) {
      action
          .actionPerformed(new ActionEvent(getGraphComponent(), e.getID(), e.getActionCommand()));
    }
  };

  newAction.putValue(Action.SHORT_DESCRIPTION, action.getValue(Action.SHORT_DESCRIPTION));

  return newAction;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:BasicGraphEditor.java

示例15: createDropDownButton

import javax.swing.AbstractAction; //导入方法依赖的package包/类
private JButton createDropDownButton() {
    Icon icon = ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/evaluator/drop_down_arrow.png", false);
    final JButton button = new DropDownButton();
    button.setIcon(icon);
    String tooltipText = NbBundle.getMessage(CodeEvaluatorUI.class, "CTL_Expressions_Dropdown_tooltip");
    button.setToolTipText(tooltipText);
    button.setEnabled(false);
    Dimension size = new Dimension(icon.getIconWidth() + 3, icon.getIconHeight() + 2);
    button.setPreferredSize(size);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setFocusable(false);
    AbstractAction action = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if ("pressed".equals(e.getActionCommand())) {
                JComponent jc = (JComponent) e.getSource();
                Point p = new Point(0, 0);
                SwingUtilities.convertPointToScreen(p, jc);
                if (!ButtonPopupSwitcher.isShown()) {
                    SwitcherTableItem[] items = createSwitcherItems();
                    ButtonPopupSwitcher.selectItem(jc, items, p.x, p.y);
                }
                //Other portion of issue 37487, looks funny if the
                //button becomes pressed
                if (jc instanceof AbstractButton) {
                    AbstractButton jb = (AbstractButton) jc;
                    jb.getModel().setPressed(false);
                    jb.getModel().setRollover(false);
                    jb.getModel().setArmed(false);
                    jb.repaint();
                }
            }
        } // actionPerformed

        @Override
        public boolean isEnabled() {
            return !getEditItemsList().isEmpty();
        }

    };
    action.putValue(Action.SMALL_ICON, icon);
    action.putValue(Action.SHORT_DESCRIPTION, tooltipText);
    button.setAction(action);
    return button;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:CodeEvaluatorUI.java


注:本文中的javax.swing.AbstractAction.putValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。