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

Last change on this file since 609 was 609, checked in by alloc, 12 years ago

AEI2:

  • Minor settings window change
File size: 2.4 KB
Line 
1package net.oni2.aeinstaller.gui.settings;
2
3import java.awt.event.ActionEvent;
4import java.awt.event.KeyEvent;
5import java.util.ResourceBundle;
6
7import javax.swing.AbstractAction;
8import javax.swing.JCheckBox;
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 private JCheckBox chkNotifyOnStart;
36
37 /**
38 * Open the settings
39 */
40 public SettingsDialog() {
41 setResizable(false);
42// setMinimumSize(new Dimension(320, (int) getSize().getHeight() + 0));
43
44 AbstractAction closeAction = new AbstractAction() {
45
46 private static final long serialVersionUID = 1L;
47
48 public void actionPerformed(ActionEvent arg0) {
49 dispose();
50 }
51 };
52 KeyStroke ksCtrlW = KeyStroke
53 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
54 getRootPane()
55 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
56 .put(ksCtrlW, "close");
57 getRootPane().getActionMap().put("close", closeAction);
58
59 initValues();
60 }
61
62 private void initValues() {
63 Settings set = Settings.getInstance();
64
65 laFModel = new LaFComboModel();
66 cmbLaF.setModel(laFModel);
67
68 chkNotifyOnStart.setSelected(set.get("notifyupdates", true));
69 }
70
71 @SuppressWarnings("unused")
72 private boolean save() {
73 Settings set = Settings.getInstance();
74
75 set.get("notifyupdates", chkNotifyOnStart.isSelected());
76
77 String oldLaf = set.get("lookandfeel", UIManager.getLookAndFeel()
78 .getClass().getName());
79 String newLaf = laFModel.getSelectedClassName();
80
81 if (!newLaf.equals(oldLaf)) {
82 set.put("lookandfeel", newLaf);
83 JOptionPane.showMessageDialog(this,
84 bundle.getString("newLaF.text"),
85 bundle.getString("newLaF.title"),
86 JOptionPane.INFORMATION_MESSAGE);
87 }
88
89 return true;
90 }
91
92}
Note: See TracBrowser for help on using the repository browser.