20 package net.sf.gridarta.gui.utils;
22 import java.awt.Component;
23 import javax.swing.Action;
24 import javax.swing.JComponent;
25 import javax.swing.KeyStroke;
28 import net.
sf.japi.swing.action.ActionBuilder;
29 import net.
sf.japi.swing.action.ActionBuilderFactory;
30 import org.jetbrains.annotations.NotNull;
31 import org.jetbrains.annotations.Nullable;
43 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta.gui.panel.tools");
58 public static Component
createLabel(@NotNull
final String key, @Nullable
final Component component) {
59 final JComponent label = component ==
null ?
ACTION_BUILDER.createLabel(key +
".text") :
ACTION_BUILDER.createLabel(component, key +
".text");
71 public static void addAction(@NotNull
final JComponent textComponent, @NotNull
final Action action) {
72 final KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
73 if (keyStroke !=
null) {
75 textComponent.getInputMap().put(keyStroke, actionId);
76 textComponent.getActionMap().put(actionId, action);