1 package com.tedpearson.ypp.market;
5 import java.awt.event.*;
6 import java.util.prefs.*;
9 * ControlPanel is a simple management utility that sets
10 * a preference for whether the PCTB client is to launch or not.
12 public class ControlPanel extends JFrame {
13 public static void main(String[] args) {
17 public ControlPanel() {
18 super("PCTB Control Panel");
19 final Preferences prefs = Preferences.userNodeForPackage(getClass());
20 final JCheckBox cb = new JCheckBox("Launch PCTB Uploader when YPP starts?", prefs.getBoolean("launchAtStartup", true));
21 final JCheckBox toPCTB = new JCheckBox("Upload to PCTB?", prefs.getBoolean("uploadToPCTB", true));
22 final JCheckBox toYarrg = new JCheckBox("Upload to Yarrg?", prefs.getBoolean("uploadToYarrg", true));
24 final JRadioButton live = new JRadioButton("Use live servers");
25 final JRadioButton testing = new JRadioButton("Use testing servers");
27 live.setSelected(prefs.getBoolean("useLiveServers", true));
28 testing.setSelected(!prefs.getBoolean("useLiveServers", true));
30 ButtonGroup liveortest = new ButtonGroup();
32 liveortest.add(testing);
34 setLayout(new GridLayout(6,1));
41 JButton but = new JButton("Save");
43 but.addActionListener(new ActionListener() {
44 public void actionPerformed(ActionEvent e) {
45 prefs.putBoolean("launchAtStartup", cb.isSelected());
46 prefs.putBoolean("uploadToPCTB", toPCTB.isSelected());
47 prefs.putBoolean("uploadToYarrg", toYarrg.isSelected());
48 prefs.putBoolean("useLiveServers", live.isSelected());
53 setLocationRelativeTo(null);
55 setSize(getWidth() + 10, getHeight() + 10);
56 setDefaultCloseOperation(EXIT_ON_CLOSE);
57 getRootPane().setDefaultButton(but);