private void setDomainColoring() {

        if(!domain_coloring_opt.isSelected()) {
            domain_coloring = false;

            domain_coloring_button.setSelected(false);
            domain_coloring_options_opt.setEnabled(false);

            if(!use_palette_domain_coloring) {
                palette_toolbar_preview.setVisible(true);
                palette_toolbar_preview_lbl.setVisible(true);
            }

            max_it_color_preview.setVisible(true);
            max_it_color_preview_lbl.setVisible(true);

            setOptions(false);

            progress.setValue(0);

            scroll_pane.getHorizontalScrollBar().setValue((int)(scroll_pane.getHorizontalScrollBar().getMaximum() / 2 - scroll_pane.getHorizontalScrollBar().getSize().getWidth() / 2));
            scroll_pane.getVerticalScrollBar().setValue((int)(scroll_pane.getVerticalScrollBar().getMaximum() / 2 - scroll_pane.getVerticalScrollBar().getSize().getHeight() / 2));

            resetImage();

            backup_orbit = null;

            whole_image_done = false;

            if(d3) {
                fiX = 0.64;
                fiY = 0.82;
                Arrays.fill(((DataBufferInt)image.getRaster().getDataBuffer()).getData(), 0, image_size * image_size, Color.BLACK.getRGB());
            }

            createThreads();

            calculation_time = System.currentTimeMillis();

            startThreads(n);

        }
        else {
            JTextField field_iterations = new JTextField();

            field_iterations.setText("" + max_iterations);

            field_iterations.addAncestorListener(new RequestFocusListener());

            String[] algs = {"Black Grid, White Circles log2", "White Grid, Black Circles log2", "Black Grid, White Circles", "White Grid, Black Circles", "Black Grid", "White Grid", "Black Grid, Contours log2", "White Grid, Contours log2", "Black Grid, Contours", "White Grid, Contours"};
            final JComboBox color_domain_algs_opt = new JComboBox(algs);
            color_domain_algs_opt.setSelectedIndex(domain_coloring_alg);
            color_domain_algs_opt.setFocusable(false);
            color_domain_algs_opt.setToolTipText("Sets the domain coloring algorithm.");

            final JCheckBox use_palette_dc = new JCheckBox("Use Current Palette");
            use_palette_dc.setFocusable(false);
            use_palette_dc.setSelected(use_palette_domain_coloring);
            use_palette_dc.setToolTipText("Enables the use of the current palette.");

            Object[] message3 = {
                " ",
                "Set the maximum number of iterations.",
                "Maximum Iterations:", field_iterations,
                " ",
                "Select the current palette or the default coloring.",
                use_palette_dc,
                " ",
                "Set the domain coloring algorithm.",
                "Domain Coloring Algorithm:", color_domain_algs_opt,
                " ",};

            int res = JOptionPane.showConfirmDialog(scroll_pane, message3, "Domain Coloring", JOptionPane.OK_CANCEL_OPTION);

            int tempIterations;

            if(res == JOptionPane.OK_OPTION) {
                try {
                    tempIterations = Integer.parseInt(field_iterations.getText());

                    if(tempIterations <= 0) {
                        main_panel.repaint();
                        JOptionPane.showMessageDialog(scroll_pane, "Maximum iterations number must be greater than 0.", "Error!", JOptionPane.ERROR_MESSAGE);
                        domain_coloring_opt.setSelected(false);
                        domain_coloring_button.setSelected(false);
                        return;
                    }

                    max_iterations = tempIterations;
                    domain_coloring_alg = color_domain_algs_opt.getSelectedIndex();
                    use_palette_domain_coloring = use_palette_dc.isSelected();

                    domain_coloring = true;

                    domain_coloring_button.setSelected(true);

                    domain_coloring_options_opt.setEnabled(true);

                    julia_map_opt.setEnabled(false);
                    julia_map_button.setEnabled(false);
                    julia_opt.setEnabled(false);
                    julia_button.setEnabled(false);
                    color_cycling_opt.setEnabled(false);
                    color_cycling_button.setEnabled(false);

                    if(!use_palette_domain_coloring) {
                        colors_menu.setEnabled(false);
                        custom_palette_button.setEnabled(false);
                        random_palette_button.setEnabled(false);
                    }
                    else {
                        exterior_de_opt.setEnabled(false);
                        bump_map_opt.setEnabled(false);

                        fake_de_opt.setEnabled(false);

                        rainbow_palette_opt.setEnabled(false);
                        out_coloring_mode_menu.setEnabled(false);
                        in_coloring_mode_menu.setEnabled(false);
                        fract_color.setEnabled(false);
                    }

                    boundary_tracing_opt.setEnabled(false);
                    periodicity_checking_opt.setEnabled(false);
                    bailout_number.setEnabled(false);
                    bailout_test_menu.setEnabled(false);

                    if(!use_palette_domain_coloring) {
                        palette_toolbar_preview.setVisible(false);
                        palette_toolbar_preview_lbl.setVisible(false);
                    }
                    else {
                        palette_toolbar_preview.setVisible(true);
                        palette_toolbar_preview_lbl.setVisible(true);
                    }

                    max_it_color_preview.setVisible(false);
                    max_it_color_preview_lbl.setVisible(false);

                    setOptions(false);

                    progress.setValue(0);

                    scroll_pane.getHorizontalScrollBar().setValue((int)(scroll_pane.getHorizontalScrollBar().getMaximum() / 2 - scroll_pane.getHorizontalScrollBar().getSize().getWidth() / 2));
                    scroll_pane.getVerticalScrollBar().setValue((int)(scroll_pane.getVerticalScrollBar().getMaximum() / 2 - scroll_pane.getVerticalScrollBar().getSize().getHeight() / 2));

                    resetImage();

                    if(d3) {
                        fiX = 0.64;
                        fiY = 0.82;
                        Arrays.fill(((DataBufferInt)image.getRaster().getDataBuffer()).getData(), 0, image_size * image_size, Color.BLACK.getRGB());
                    }

                    backup_orbit = null;

                    whole_image_done = false;

                    createThreads();

                    calculation_time = System.currentTimeMillis();

                    startThreads(n);

                }
                catch(Exception e) {
                    JOptionPane.showMessageDialog(scroll_pane, "Illegal Argument!", "Error!", JOptionPane.ERROR_MESSAGE);
                    domain_coloring_opt.setSelected(false);
                    domain_coloring_button.setSelected(false);
                    main_panel.repaint();
                    return;
                }
            }
            else {
                domain_coloring_opt.setSelected(false);
                domain_coloring_button.setSelected(false);
                main_panel.repaint();
                return;
            }
        }
    }