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

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

AEI2-import

File size: 2.7 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.JFrame;
12import javax.swing.JOptionPane;
13import javax.swing.KeyStroke;
14import javax.swing.SwingUtilities;
15import javax.swing.UIManager;
16
17import net.oni2.aeinstaller.backend.Settings;
18
19import org.javabuilders.BuildResult;
20import org.javabuilders.swing.SwingJavaBuilder;
21
22/**
23 * @author Christian Illy
24 */
25public class SettingsDialog extends JFrame {
26 private static final long serialVersionUID = -5719515325671846620L;
27
28 private ResourceBundle bundle = ResourceBundle.getBundle(getClass()
29 .getName());
30 @SuppressWarnings("unused")
31 private BuildResult result = SwingJavaBuilder.build(this, bundle);
32
33 private static SettingsDialog openWindow = null;
34
35 private JComboBox cmbLaF;
36 private LaFComboModel laFModel;
37
38 /**
39 * Open the Settings dialog if not currently opened or brings the existing
40 * one to front
41 */
42 public static void openWindow() {
43 if (openWindow != null) {
44 SwingUtilities.invokeLater(new Runnable() {
45
46 @Override
47 public void run() {
48 openWindow.toFront();
49 openWindow.repaint();
50 }
51 });
52 } else {
53 new SettingsDialog().setVisible(true);
54 }
55 }
56
57 private SettingsDialog() {
58 openWindow = this;
59 setMinimumSize(new Dimension(500, (int) getSize().getHeight() + 0));
60
61 AbstractAction closeAction = new AbstractAction() {
62
63 private static final long serialVersionUID = 1L;
64
65 public void actionPerformed(ActionEvent arg0) {
66 dispose();
67 }
68 };
69 KeyStroke ksCtrlW = KeyStroke
70 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
71 getRootPane()
72 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
73 .put(ksCtrlW, "close");
74 getRootPane().getActionMap().put("close", closeAction);
75
76 initValues();
77 }
78
79 private void initValues() {
80 Settings set = Settings.getInstance();
81
82 laFModel = new LaFComboModel();
83 cmbLaF.setModel(laFModel);
84 }
85
86 @SuppressWarnings("unused")
87 private void close() {
88 openWindow = null;
89 }
90
91 @SuppressWarnings("unused")
92 private boolean save() {
93 Settings set = Settings.getInstance();
94
95 String oldLaf = set.get("lookandfeel",
96 UIManager.getSystemLookAndFeelClassName());
97 String newLaf = laFModel.getSelectedClassName();
98
99 if (!newLaf.equals(oldLaf)) {
100 set.put("lookandfeel", newLaf);
101 JOptionPane.showMessageDialog(this,
102 bundle.getString("newLaF.text"),
103 bundle.getString("newLaF.title"),
104 JOptionPane.INFORMATION_MESSAGE);
105 }
106
107 return true;
108 }
109
110}
Note: See TracBrowser for help on using the repository browser.