1 | // Jomic - a viewer for comic book archives. |
2 | // Copyright (C) 2004-2011 Thomas Aglassinger |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | package net.sf.jomic.ui; |
17 | |
18 | import java.awt.BorderLayout; |
19 | import java.awt.Container; |
20 | import java.awt.GridBagConstraints; |
21 | import java.awt.GridBagLayout; |
22 | |
23 | import javax.swing.JButton; |
24 | import javax.swing.JFrame; |
25 | import javax.swing.JLabel; |
26 | import javax.swing.JPanel; |
27 | import javax.swing.JTabbedPane; |
28 | |
29 | import net.sf.jomic.common.Settings; |
30 | import net.sf.jomic.tools.LocaleTools; |
31 | |
32 | /** |
33 | * Frame to change settings. |
34 | * |
35 | * @author Thomas Aglassinger |
36 | */ |
37 | public class SettingsFrame extends JFrame |
38 | { |
39 | |
40 | private ColorButton borderButton; |
41 | private JButton cancelButton; |
42 | private LocaleTools localeTools; |
43 | private JButton okButton; |
44 | private Settings settings; |
45 | private JTabbedPane tabbedPane; |
46 | |
47 | // TODO: localize |
48 | public SettingsFrame() { |
49 | settings = Settings.instance(); |
50 | localeTools = LocaleTools.instance(); |
51 | |
52 | Container contentPane = getContentPane(); |
53 | |
54 | contentPane.setLayout(new BorderLayout()); |
55 | tabbedPane = new JTabbedPane(); |
56 | tabbedPane.add("View", createViewPane()); |
57 | tabbedPane.add("Cache", createCachePane()); |
58 | contentPane.add(tabbedPane, BorderLayout.CENTER); |
59 | contentPane.add(createButtonPane(), BorderLayout.SOUTH); |
60 | getRootPane().setDefaultButton(okButton); |
61 | } |
62 | |
63 | public void dispose() { |
64 | if (borderButton != null) { |
65 | borderButton.dispose(); |
66 | } |
67 | super.dispose(); |
68 | } |
69 | |
70 | private JPanel createButtonPane() { |
71 | JPanel result = new JPanel(new GridBagLayout()); |
72 | GridBagConstraints c = new GridBagConstraints(); |
73 | |
74 | // TODO: right-align buttons |
75 | // TODO: use Cancel+OK under Mac OS, and OK+Cancel under other platforms |
76 | c.gridx = 0; |
77 | c.gridy = 0; |
78 | c.weightx = 1.0; |
79 | result.add(new JLabel("")); |
80 | cancelButton = new JButton(localeTools.getCancelText()); |
81 | c.gridx = 1; |
82 | c.weightx = 0.0; |
83 | result.add(cancelButton, c); |
84 | okButton = new JButton(localeTools.getOkText()); |
85 | c.gridx = 2; |
86 | result.add(okButton, c); |
87 | return result; |
88 | } |
89 | |
90 | private JPanel createCachePane() { |
91 | JPanel result = new JPanel(); |
92 | |
93 | return result; |
94 | } |
95 | |
96 | private JPanel createViewPane() { |
97 | JPanel result = new JPanel(new GridBagLayout()); |
98 | GridBagConstraints c = new GridBagConstraints(); |
99 | JLabel borderLabel = new JLabel("Border color"); |
100 | |
101 | c.gridx = 0; |
102 | c.gridy = 0; |
103 | result.add(borderLabel, c); |
104 | |
105 | borderButton = new ColorButton(settings.getFillColor()); |
106 | c.gridx = 1; |
107 | result.add(borderButton, c); |
108 | return result; |
109 | } |
110 | } |