01: /**
02: * This is a panel where a language can be choosen from.
03: *
04: * @author Henrik Falk
05: * @see com.memoire.vainstall.VALanguageStep
06: */package com.memoire.vainstall.gui;
07:
08: import java.awt.*;
09: import javax.swing.*;
10: import javax.swing.border.*;
11: import com.memoire.vainstall.VAGlobals;
12: import com.memoire.vainstall.VALanguageStep;
13:
14: public class VALanguagePanel extends VAPanel implements VALanguageStep {
15: /**
16: * The listbox from where we can select languages.
17: */
18: JList languageJList;
19:
20: /**
21: * Default constructor
22: */
23: public VALanguagePanel() {
24: super ();
25:
26: setLayout(new BoxLayout(this , BoxLayout.X_AXIS));
27:
28: JPanel pnMain = new JPanel();
29: pnMain.setBorder(new CompoundBorder(new EtchedBorder(),
30: new EmptyBorder(new Insets(5, 5, 5, 5))));
31: pnMain.setLayout(new BorderLayout());
32: JLabel lbTitle = new JLabel(" " + VAGlobals.i18n("UI_Language"));
33: lbTitle.setFont(lbTitle.getFont().deriveFont(Font.BOLD, 20));
34: lbTitle.setOpaque(true);
35: lbTitle.setBorder(new EmptyBorder(new Insets(5, 0, 5, 0)));
36: lbTitle.setBackground(pnMain.getBackground().darker());
37: lbTitle.setForeground(Color.white);
38:
39: languageJList = new JList(VAGlobals.getSupportedLanguages());
40: languageJList
41: .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
42: languageJList.setSelectedIndex(VAGlobals.suggestLanguage());
43: JScrollPane spLanguage = new JScrollPane(languageJList);
44:
45: pnMain.add(BorderLayout.NORTH, lbTitle);
46: pnMain.add(BorderLayout.CENTER, spLanguage);
47:
48: JComponent pnImage = VAImagePanel.IMAGE_PANEL;
49: add(pnImage);
50: add(pnMain);
51: }
52:
53: /**
54: * Returns the selected language in the same format as written
55: * in the *.vai file.
56: * @return String
57: */
58: public String getLanguage() {
59: // set default language
60: String language = "english";
61:
62: if (languageJList.getSelectedIndex() != -1) {
63: for (int i = 0; i < VAGlobals.languages.length; i++) {
64: if (VAGlobals.languages[i][1].equals(languageJList
65: .getSelectedValue()) == true) {
66: language = VAGlobals.languages[i][0];
67: }
68: }
69: }
70:
71: return language;
72: }
73:
74: }
|