1 package net.pterodactylus.jsite.gui;
3 import javax.swing.AbstractAction;
4 import javax.swing.Action;
5 import javax.swing.Icon;
7 import net.pterodactylus.jsite.i18n.I18n;
10 * Helper class that initializes actions with values from {@link I18n}.
12 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
15 public abstract class I18nAction extends AbstractAction {
18 * Creates a new action that uses the given name as base name to get values
22 * The base name of the action
24 public I18nAction(String i18nName) {
29 * Creates a new action that uses the given name as base name to get values
30 * from {@link I18n} and the given icon.
33 * The base name of the action
35 * The icon for the action
37 public I18nAction(String i18nName, Icon icon) {
38 this(i18nName, true, icon);
42 * Creates a new action that uses the given name as base name to get values
46 * The base name of the action
48 * Whether the action should be enabled
50 public I18nAction(String i18nName, boolean enabled) {
51 this(i18nName, enabled, null);
55 * Creates a new action that uses the given name as base name to get values
56 * from {@link I18n} and the given icon.
59 * The base name of the action
61 * Whether the action should be enabled
63 * The icon for the action
65 public I18nAction(String i18nName, boolean enabled, Icon icon) {
66 putValue(Action.NAME, I18n.get(i18nName + ".name"));
67 putValue(Action.MNEMONIC_KEY, I18n.getKey(i18nName + ".mnemonic"));
68 putValue(Action.ACCELERATOR_KEY, I18n.getKeyStroke(i18nName + ".accelerator"));
69 putValue(Action.SHORT_DESCRIPTION, I18n.get(i18nName + ".shortDescription"));
70 putValue(Action.LONG_DESCRIPTION, I18n.get(i18nName + ".longDescription"));
72 putValue(Action.SMALL_ICON, icon);