Make I18n class non-static.
[jkeytool.git] / src / net / pterodactylus / util / i18n / gui / I18nMenu.java
1 /*
2  * jSite2 - I18nMenu.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.util.i18n.gui;
21
22 import javax.swing.JMenu;
23
24 import net.pterodactylus.util.i18n.I18n;
25 import net.pterodactylus.util.i18n.I18nable;
26
27 /**
28  * Menu that receives its properties from {@link I18n}.
29  *
30  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
31  */
32 public class I18nMenu extends JMenu implements I18nable {
33
34         /** The {@link I18n} basename. */
35         private final String i18nBasename;
36
37         /**
38          * Creates a new menu with the given {@link I18n} basename.
39          *
40          * @param i18n
41          *            The I18n container
42          * @param i18nBasename
43          *            The basename of the {@link I18n} properties
44          */
45         public I18nMenu(I18n i18n, String i18nBasename) {
46                 this.i18nBasename = i18nBasename;
47                 updateI18n(i18n);
48         }
49
50         //
51         // INTERFACE I18nable
52         //
53
54         /**
55          * {@inheritDoc}
56          */
57         public void updateI18n(I18n i18n) {
58                 setText(i18n.get(i18nBasename + ".name"));
59                 setMnemonic(i18n.getKey(i18nBasename + ".mnemonic"));
60         }
61
62 }