本文整理匯總了Java中javax.swing.Action.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Action.getValue方法的具體用法?Java Action.getValue怎麽用?Java Action.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.Action
的用法示例。
在下文中一共展示了Action.getValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeHTML
import javax.swing.Action; //導入方法依賴的package包/類
private static String makeHTML(final Action action, boolean addLinkTag, boolean normalFont) {
if (action == null) {
return "";
}
String html = (String) action.getValue(Action.NAME);
if (addLinkTag) {
if (action instanceof ResourceAction) {
String iconName = ((ResourceAction) action).getIconName();
if (iconName != null) {
URL iconUrl = Tools.getResource("icons/16/" + iconName);
if (iconUrl != null) {
html = "<img src=\"" + iconUrl.toString()
+ "\" border=\"0\" style=\"border:none;vertical-align:middle;\"/> " + html;
}
}
}
html = "<a href=\"#\"" + (normalFont ? " style=\"text-decoration:none;color:#222244;\"" : "") + ">" + html
+ "</a>";
}
return html;
}
示例2: assignAccelerator
import javax.swing.Action; //導入方法依賴的package包/類
private static void assignAccelerator(Keymap km, Action action, JMenuItem item) {
if (item.getAccelerator() == null){
KeyStroke ks = (KeyStroke)action.getValue(Action.ACCELERATOR_KEY);
if (ks!=null) {
item.setMnemonic(ks.getKeyCode());
} else {
// Try to get the accelerator from keymap
if (km != null) {
KeyStroke[] keys = km.getKeyStrokesForAction(action);
if (keys != null && keys.length > 0) {
item.setMnemonic(keys[0].getKeyCode());
}
}
}
}
}
示例3: addAction
import javax.swing.Action; //導入方法依賴的package包/類
private void addAction (Action action) {
String name = (String) action.getValue(Action.NAME);
LinkButton btn = new LinkButton(name);
btn.addActionListener(action);
btn.addFocusListener(focusListener);
if (notEmpty) {
JLabel separator = new javax.swing.JLabel();
separator.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(2, 0, 2, 0),
BorderFactory.createLineBorder(Color.BLACK, 1)
));
horizontalSeqGroup
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(separator)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
verticalParallelGroup
.addComponent(separator, GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE);
}
horizontalSeqGroup
.addComponent(btn, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
verticalParallelGroup
.addComponent(btn, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
notEmpty = true;
}
示例4: testMethodCallDirectly
import javax.swing.Action; //導入方法依賴的package包/類
public void testMethodCallDirectly() {
ActionEvent e = new ActionEvent(this, 0, "");
TC tc = new TC();
final String img = "org/openide/windows/icon.png";
Action instance = TopComponent.openAction(tc, "Ahoj", img, false);
instance.actionPerformed(e);
tc.close();
assertEquals("Opened once", 1, tc.cntOpen);
assertEquals("Activated once", 1, tc.cntRequest);
Icon icon = (Icon) instance.getValue(Action.SMALL_ICON);
assertEquals("Width", 133, icon.getIconWidth());
assertEquals("Height", 133, icon.getIconHeight());
assertEquals("Name", "Ahoj", instance.getValue(Action.NAME));
}
示例5: configurePropertiesFromAction
import javax.swing.Action; //導入方法依賴的package包/類
@Override
protected void configurePropertiesFromAction(Action a) {
super.configurePropertiesFromAction(a);
if (a != null) {
setRolloverEnabled(true);
String key = (String) a.getValue(FreeColAction.BUTTON_IMAGE);
ImageIcon bi = new ImageIcon(ResourceManager.getImage(key));
setIcon(bi);
key = (String) a.getValue(FreeColAction.BUTTON_ROLLOVER_IMAGE);
setRolloverIcon(new ImageIcon(ResourceManager.getImage(key)));
key = (String) a.getValue(FreeColAction.BUTTON_PRESSED_IMAGE);
setPressedIcon(new ImageIcon(ResourceManager.getImage(key)));
key = (String) a.getValue(FreeColAction.BUTTON_DISABLED_IMAGE);
setDisabledIcon(new ImageIcon(ResourceManager.getImage(key)));
setToolTipText((String) a.getValue(FreeColAction.NAME));
setText(null);
setFocusPainted(false);
setContentAreaFilled(false);
setBorderPainted(false);
setSize(bi.getIconWidth(), bi.getIconHeight());
}
}
示例6: addAcceleretors
import javax.swing.Action; //導入方法依賴的package包/類
private void addAcceleretors(Action a, JMenuItem item, JTextComponent target) {
// Try to get the accelerator
Keymap km = target.getKeymap();
if (km != null) {
KeyStroke[] keys = km.getKeyStrokesForAction(a);
if ((keys != null) && (keys.length > 0)) {
item.setAccelerator(keys[0]);
} else if (a != null) {
KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
if (ks != null) {
item.setAccelerator(ks);
}
}
}
}
示例7: playSound
import javax.swing.Action; //導入方法依賴的package包/類
/**
* If necessary, invokes {@code actionPerformed} on
* {@code audioAction} to play a sound.
* The {@code actionPerformed} method is invoked if the value of
* the {@code "AuditoryCues.playList"} default is a {@code
* non-null} {@code Object[]} containing a {@code String} entry
* equal to the name of the {@code audioAction}.
*
* @param audioAction an Action that knows how to render the audio
* associated with the system or user activity
* that is occurring; a value of {@code null}, is
* ignored
* @throws ClassCastException if {@code audioAction} is {@code non-null}
* and the value of the default {@code "AuditoryCues.playList"}
* is not an {@code Object[]}
* @since 1.4
*/
protected void playSound(Action audioAction) {
if (audioAction != null) {
Object[] audioStrings = (Object[])
UIManager.get("AuditoryCues.playList");
if (audioStrings != null) {
// create a HashSet to help us decide to play or not
HashSet<Object> audioCues = new HashSet<Object>();
for (Object audioString : audioStrings) {
audioCues.add(audioString);
}
// get the name of the Action
String actionName = (String)audioAction.getValue(Action.NAME);
// if the actionName is in the audioCues HashSet, play it.
if (audioCues.contains(actionName)) {
audioAction.actionPerformed(new
ActionEvent(this, ActionEvent.ACTION_PERFORMED,
actionName));
}
}
}
}
示例8: PresenterUpdater
import javax.swing.Action; //導入方法依賴的package包/類
private PresenterUpdater(int type, Action action) {
if (action == null) {
throw new IllegalArgumentException("action must not be null"); // NOI18N
}
this.type = type;
this.actionName = (String) action.getValue(Action.NAME);
this.action = action;
if (type == TOOLBAR) {
presenter = new JButton();
useActionSelectedProperty = false;
} else { // MENU or POPUP
useActionSelectedProperty = (action.getValue(AbstractEditorAction.PREFERENCES_KEY_KEY) != null);
if (useActionSelectedProperty) {
presenter = new LazyJCheckBoxMenuItem();
presenter.setSelected(isActionSelected());
} else {
presenter = new LazyJMenuItem();
}
}
action.addPropertyChangeListener(WeakListeners.propertyChange(this, action));
if (type == MENU) {
listenedContextActions = new WeakSet<Action>();
EditorRegistryWatcher.get().registerPresenterUpdater(this); // Includes notification of active component
} else {
listenedContextActions = null;
}
presenter.addActionListener(this);
updatePresenter(null); // Not active yet => mark updates pending
}
示例9: reuseShortcut
import javax.swing.Action; //導入方法依賴的package包/類
private void reuseShortcut(Action action) {
Object key = action.getValue(Action.ACCELERATOR_KEY);
if (key instanceof KeyStroke) {
InputMap inputMap = tc.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put((KeyStroke)key, action.getValue(Action.NAME));
}
}
示例10: addActionsToMap
import javax.swing.Action; //導入方法依賴的package包/類
/** Creates map with [name, action] pairs from the given
* array of actions.
*/
public static void addActionsToMap(Map<String, Action> map, Action[] actions, String logActionsType) {
boolean fineLoggable = LOG.isLoggable(Level.FINE);
if (fineLoggable) {
LOG.fine(logActionsType + " start --------------------\n");
}
for (int i = 0; i < actions.length; i++) {
Action a = actions[i];
if (a == null) {
LOG.info("actions[] contains null at index " + i +
((i > 0) ? ". Preceding action is " + actions[i - 1] : "."));
continue;
}
String name = (String) a.getValue(Action.NAME);
if (name == null) {
LOG.info("Null Action.NAME property of action " + a);
continue;
}
if (fineLoggable) {
String overriding = map.containsKey(name) ? " OVERRIDING\n" : "\n"; // NOI18N
LOG.fine(" " + name + ": " + a + overriding); // NOI18N
}
map.put(name, a); // NOI18N
}
if (fineLoggable) {
LOG.fine(logActionsType + " end ----------------------\n");
}
}
示例11: makeHTML
import javax.swing.Action; //導入方法依賴的package包/類
/**
* Creates the HTML text which will represent the link button.
*
* @param action
* @return
*/
private static String makeHTML(final Action action) {
String name = (String) action.getValue(Action.NAME);
if (name == null || name.trim().isEmpty()) {
return "";
}
// if only part of the text should appear as link, <a href> tag is defined in i18n
if (name.contains("<") || name.contains(">")) {
return name;
}
URL iconUrl = null;
if (action instanceof ResourceAction) {
String iconName = ((ResourceAction) action).getIconName();
if (iconName != null) {
iconUrl = Tools.getResource("icons/16/" + iconName);
}
}
if (iconUrl != null) {
return String.format(TEMPLATE_ICON_HTML, iconUrl.toString(), name);
} else {
if (Boolean.parseBoolean(String.valueOf(action.getValue(PROPERTY_BOLD)))) {
return String.format(TEMPLATE_HTML_BOLD, name);
} else {
return String.format(TEMPLATE_HTML, name);
}
}
}
示例12: removeMenuItem
import javax.swing.Action; //導入方法依賴的package包/類
protected void removeMenuItem(JMenuItem itemToRemove) {
Action a = itemToRemove.getAction();
// start by searching this menu
XJMenu menuToUse = this;
int firstIndex = firstPluginItem;
// keep track of the parent menu
XJMenu parentMenu = null;
// if the action has a menu path set, navigate the path to find the
// right menu.
String[] menuPath = (String[])a.getValue(GateConstants.MENU_PATH_KEY);
if(menuPath != null) {
PATH_ELEMENT: for(String pathElement : menuPath) {
int i;
for(i = firstIndex; i < menuToUse.getItemCount(); i++) {
JMenuItem item = menuToUse.getItem(i);
if(item instanceof XJMenu && item.getText().equals(pathElement)) {
// found the menu for this path element, move on to the next one
firstIndex = 0;
parentMenu = menuToUse;
menuToUse = (XJMenu)item;
continue PATH_ELEMENT;
}
}
// we've reached the end of a menu without finding the sub-menu
// we were looking for. This shouldn't happen, but if it does then
// we can ignore it as if there's no menu to remove the thing from
// then there's nothing to remove either.
return;
}
}
// we have a menu to remove the item from: remove it
menuToUse.remove(itemToRemove);
if(menuToUse.getItemCount() == 0 && parentMenu != null) {
// sub-menu is empty, remove it from parent
parentMenu.remove(menuToUse);
}
}
示例13: addAcceleretors
import javax.swing.Action; //導入方法依賴的package包/類
private static void addAcceleretors(Action a, JMenuItem item, JTextComponent target) {
// Try to get the accelerator
Keymap km = (target == null) ? BaseKit.getKit(BaseKit.class).getKeymap() :
target.getKeymap();
if (km != null) {
KeyStroke[] keys = km.getKeyStrokesForAction(a);
if (keys != null && keys.length > 0) {
boolean added = false;
for (int i = 0; i<keys.length; i++){
if ((keys[i].getKeyCode() == KeyEvent.VK_MULTIPLY) ||
keys[i].getKeyCode() == KeyEvent.VK_ADD){
item.setMnemonic(keys[i].getKeyCode());
added = true;
break;
}
}
if (added == false) {
item.setMnemonic(keys[0].getKeyCode());
}
}else if (a!=null){
KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
if (ks!=null) {
item.setMnemonic(ks.getKeyCode());
}
}
}
}
示例14: getValue
import javax.swing.Action; //導入方法依賴的package包/類
public Object getValue(String key) {
if (attrs != null && attrs.containsKey(key)) {
return attrs.get(key);
}
Object ret = GeneralAction.extractCommonAttribute(map, this, key);
if (ret != null) {
return ret;
}
Action a = findAction();
return a == null ? null : a.getValue(key);
}
示例15: getGlobalActionProperty
import javax.swing.Action; //導入方法依賴的package包/類
public static Object getGlobalActionProperty(Map<String,?> attrs, String key) {
Object value = null;
String actionName = (String) attrs.get(Action.NAME);
SearchableEditorKit globalKit = getGlobalActionsKit();
if (globalKit != null) {
Action a = globalKit.getAction(actionName);
if (a != null) {
value = a.getValue(key);
}
}
return value;
}