public PreferencesPopup(Window window, ToolboxPanel toolboxPanel)
    {
        super(window, "Set Custom Colors", true);

        setLocationRelativeTo(window);

        this.toolboxPanel = toolboxPanel;

        scheme = new ColorScheme(ColorScheme.CUSTOM_SCHEME.toString(), ColorScheme.CUSTOM_SCHEME);

        loadExampleMap();

        GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);

        JPanel content = new JPanel(new GridBagLayout());

        JPanel buttonBar = new JPanel(new GridBagLayout());

        colorButtons = new ColorButton[ColorScheme.COLOR_LABELS.length];

        for (int i = 0; i < colorButtons.length; i++)
        {
            String colorLabel = ColorScheme.COLOR_LABELS[i];
            final ColorButton cb = new ColorButton(colorLabel, scheme.get(colorLabel));
            colorButtons[i] = cb;

            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent e)
                {
                    Color selection = JColorChooser.showDialog(getParent(), "Select Color", scheme.get(cb.getLabel()));
                    if (selection != null)
                    {
                        scheme.setColor(cb.getLabel(), selection);
                        cb.setColor(selection);
                    }
                    example.repaint();
                }
            };

            cb.addActionListener(al);
            buttonBar.add(cb, gbc);
            gbc.gridy++;
        }

        save = new JButton("Save");
        cancel = new JButton("Cancel");

        ActionListener saveCancelListener = new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                if (save.equals(e.getSource()))
                {
                    saveScheme();
                }
                else if (cancel.equals(e.getSource()))
                {
                    loadScheme();
                }
                setVisible(false);
            }
        };

        save.addActionListener(saveCancelListener);
        cancel.addActionListener(saveCancelListener);

        JPanel saveCancelPanel = new JPanel();
        saveCancelPanel.add(save);
        saveCancelPanel.add(cancel);

        buttonBar.add(saveCancelPanel, gbc);

        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.NORTHWEST;
        gbc.weightx = 0.0f;
        content.add(buttonBar, gbc);

        gbc.gridx = 1;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.anchor = GridBagConstraints.CENTER;
        gbc.weightx = 1.0f;
        gbc.weighty = 1.0f;
        content.add(example, gbc);

        add(new JScrollPane(content));

        pack();
        setSize(640, getHeight());
        setMinimumSize(getSize());
        setResizable(false);
    }