Add i18n components.
[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 i18nBasename
41          *            The basename of the {@link I18n} properties
42          */
43         public I18nMenu(String i18nBasename) {
44                 this.i18nBasename = i18nBasename;
45                 updateI18n();
46         }
47
48         //
49         // INTERFACE I18nable
50         //
51
52         /**
53          * {@inheritDoc}
54          */
55         public void updateI18n() {
56                 setText(I18n.get(i18nBasename + ".name"));
57                 setMnemonic(I18n.getKey(i18nBasename + ".mnemonic"));
58         }
59
60 }