source: AE/installer2/src/net/oni2/aeinstaller/gui/settings/SettingsDialog.java@ 600

Last change on this file since 600 was 593, checked in by alloc, 12 years ago
File size: 2.2 KB
Line 
1package net.oni2.aeinstaller.gui.settings;
2
3import java.awt.Dimension;
4import java.awt.event.ActionEvent;
5import java.awt.event.KeyEvent;
6import java.util.ResourceBundle;
7
8import javax.swing.AbstractAction;
9import javax.swing.JComboBox;
10import javax.swing.JComponent;
11import javax.swing.JDialog;
12import javax.swing.JOptionPane;
13import javax.swing.KeyStroke;
14import javax.swing.UIManager;
15
16import net.oni2.aeinstaller.backend.Settings;
17
18import org.javabuilders.BuildResult;
19import org.javabuilders.swing.SwingJavaBuilder;
20
21/**
22 * @author Christian Illy
23 */
24public class SettingsDialog extends JDialog {
25 private static final long serialVersionUID = -5719515325671846620L;
26
27 private ResourceBundle bundle = ResourceBundle.getBundle(getClass()
28 .getName());
29 @SuppressWarnings("unused")
30 private BuildResult result = SwingJavaBuilder.build(this, bundle);
31
32 private JComboBox cmbLaF;
33 private LaFComboModel laFModel;
34
35 /**
36 * Open the settings
37 */
38 public SettingsDialog() {
39 setMinimumSize(new Dimension(500, (int) getSize().getHeight() + 0));
40
41 AbstractAction closeAction = new AbstractAction() {
42
43 private static final long serialVersionUID = 1L;
44
45 public void actionPerformed(ActionEvent arg0) {
46 dispose();
47 }
48 };
49 KeyStroke ksCtrlW = KeyStroke
50 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
51 getRootPane()
52 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
53 .put(ksCtrlW, "close");
54 getRootPane().getActionMap().put("close", closeAction);
55
56 initValues();
57 }
58
59 private void initValues() {
60 Settings set = Settings.getInstance();
61
62 laFModel = new LaFComboModel();
63 cmbLaF.setModel(laFModel);
64 }
65
66 @SuppressWarnings("unused")
67 private boolean save() {
68 Settings set = Settings.getInstance();
69
70 String oldLaf = set.get("lookandfeel",
71 UIManager.getLookAndFeel().getClass().getName());
72 String newLaf = laFModel.getSelectedClassName();
73
74 if (!newLaf.equals(oldLaf)) {
75 set.put("lookandfeel", newLaf);
76 JOptionPane.showMessageDialog(this,
77 bundle.getString("newLaF.text"),
78 bundle.getString("newLaF.title"),
79 JOptionPane.INFORMATION_MESSAGE);
80 }
81
82 return true;
83 }
84
85}
Note: See TracBrowser for help on using the repository browser.