summaryrefslogtreecommitdiff
path: root/src/com/delwink/icebox/swing/SettingsDialog.java
blob: 80a0df7fb038f33eab5bb8dd03a57ee5061bf91b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * IceBox - inventory management software for restaurants
 * Copyright (C) 2016 Delwink, LLC
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, version 3 only.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.delwink.icebox.swing;

import com.delwink.icebox.Config;
import com.delwink.icebox.lang.Lang;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;

/**
 * Dialog for customizing IceBox.
 * @author David McMackins II
 */
public class SettingsDialog extends JDialog {
    private final JButton CANCEL_BUTTON, OK_BUTTON;
    private final JCheckBox SETLAF;
    
    public SettingsDialog(Frame parent) {
        super(parent, Lang.get("Setting.dialogTitle"));
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setModal(true);
        
        SETLAF = new JCheckBox(Lang.get("Setting.setlaf"));
        SETLAF.setSelected(Config.get("setlaf").equals("y"));
        JPanel setlafPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        setlafPanel.add(SETLAF);
        
        CANCEL_BUTTON = new JButton(Lang.get("cancel"));
        CANCEL_BUTTON.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });
        
        OK_BUTTON = new JButton(Lang.get("ok"));
        OK_BUTTON.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Config.put("setlaf", SETLAF.isSelected() ? "y" : "n");
                
                dispose();
            }
        });
        
        JPanel buttonBox = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        buttonBox.add(CANCEL_BUTTON);
        buttonBox.add(OK_BUTTON);
        
        setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
        add(setlafPanel);
        add(buttonBox);
        
        pack();
        centorOnParent();
    }
}