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);
Utility class implementing Action related functions.
Utility class for Swing related functions.
static final ActionBuilder ACTION_BUILDER
Action Builder.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
Base package of all Gridarta classes.
static String getActionId(@NotNull final Action action)
Returns an Action's ID string.
Utility class for ActionBuilder related functions.
static Component createLabel(@NotNull final String key, @Nullable final Component component)
Create a javax.swing.JLabel instance.
SwingUtils()
Private constructor to prevent instantiation.
static void addAction(@NotNull final JComponent textComponent, @NotNull final Action action)
Adds an accelerator key for a component.