1 /***************************************************************************
2  *                   (C) Copyright 2003-2010 - Stendhal                    *
3  ***************************************************************************
4  ***************************************************************************
5  *                                                                         *
6  *   This program is free software; you can redistribute it and/or modify  *
7  *   it under the terms of the GNU General Public License as published by  *
8  *   the Free Software Foundation; either version 2 of the License, or     *
9  *   (at your option) any later version.                                   *
10  *                                                                         *
11  ***************************************************************************/
12 package games.stendhal.client.gui.settings;
13 
14 import java.awt.Frame;
15 import java.awt.event.ActionEvent;
16 import java.awt.event.ActionListener;
17 
18 import javax.swing.BorderFactory;
19 import javax.swing.JButton;
20 import javax.swing.JDialog;
21 import javax.swing.JTabbedPane;
22 
23 import games.stendhal.client.gui.WindowUtils;
24 import games.stendhal.client.gui.layout.SBoxLayout;
25 
26 /**
27  * Dialog for game settings.
28  */
29 @SuppressWarnings("serial")
30 public class SettingsDialog extends JDialog {
31 	/**
32 	 * Create a new SettingsDialog.
33 	 *
34 	 * @param parent parent window, or <code>null</code>
35 	 */
SettingsDialog(Frame parent)36 	public SettingsDialog(Frame parent) {
37 		super(parent, "Settings");
38 		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
39 		int pad = SBoxLayout.COMMON_PADDING;
40 		setLayout(new SBoxLayout(SBoxLayout.VERTICAL, pad));
41 		JTabbedPane tabs = new JTabbedPane();
42 		add(tabs);
43 		tabs.add("General", new GeneralSettings().getComponent());
44 		tabs.add("Visuals", new VisualSettings().getComponent());
45 		tabs.add("Sound", new SoundSettings().getComponent());
46 		setResizable(false);
47 		JButton closeButton = new JButton("Close");
48 		closeButton.setAlignmentX(RIGHT_ALIGNMENT);
49 		closeButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(pad, pad, pad, pad),
50 				closeButton.getBorder()));
51 		closeButton.addActionListener(new ActionListener() {
52 			@Override
53 			public void actionPerformed(ActionEvent arg0) {
54 				dispose();
55 			}
56 		});
57 		add(closeButton);
58 		WindowUtils.closeOnEscape(this);
59 		WindowUtils.watchFontSize(this);
60 		WindowUtils.trackLocation(this, "settings", false);
61 		pack();
62 	}
63 }
64