Example usage for javax.swing JFormattedTextField JFormattedTextField

List of usage examples for javax.swing JFormattedTextField JFormattedTextField

Introduction

In this page you can find the example usage for javax.swing JFormattedTextField JFormattedTextField.

Prototype

public JFormattedTextField(AbstractFormatterFactory factory) 

Source Link

Document

Creates a JFormattedTextField with the specified AbstractFormatterFactory.

Usage

From source file:edu.snu.leader.discrete.simulator.SimulatorLauncherGUI.java

/**
 * Create the frame./*from w  w w. ja  v  a 2  s  . co  m*/
 */
public SimulatorLauncherGUI() {
    NumberFormat countFormat = NumberFormat.getNumberInstance();
    countFormat.setParseIntegerOnly(true);

    NumberFormat doubleFormat = NumberFormat.getNumberInstance();
    doubleFormat.setMinimumIntegerDigits(1);
    doubleFormat.setMaximumFractionDigits(10);

    setTitle("Simulator");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 515, 340);
    setResizable(false);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    contentPane.add(tabbedPane, BorderLayout.CENTER);

    JPanel panelTab1 = new JPanel();
    tabbedPane.addTab("Simulator", null, panelTab1, null);

    JPanel panelAgentCount = new JPanel();
    panelTab1.add(panelAgentCount);

    JLabel lblNewLabel = new JLabel("Agent Count");
    panelAgentCount.add(lblNewLabel);

    sliderAgent = new JSlider();
    panelAgentCount.add(sliderAgent);
    sliderAgent.setValue(10);
    sliderAgent.setSnapToTicks(true);
    sliderAgent.setPaintTicks(true);
    sliderAgent.setPaintLabels(true);
    sliderAgent.setMinorTickSpacing(10);
    sliderAgent.setMajorTickSpacing(10);
    sliderAgent.setMinimum(10);
    sliderAgent.setMaximum(70);

    sliderAgent.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent arg0) {
            Integer spinnerValue = (Integer) spinnerMaxEaten.getValue();
            if (spinnerValue > sliderAgent.getValue()) {
                spinnerValue = sliderAgent.getValue();
            }
            spinnerMaxEaten.setModel(new SpinnerNumberModel(spinnerValue, new Integer(0),
                    new Integer(sliderAgent.getValue()), new Integer(1)));
            JFormattedTextField tfMaxEaten = ((JSpinner.DefaultEditor) spinnerMaxEaten.getEditor())
                    .getTextField();
            tfMaxEaten.setEditable(false);
        }
    });

    JPanel panelCommType = new JPanel();
    panelTab1.add(panelCommType);

    JLabel lblNewLabel_1 = new JLabel("Communication Type");
    panelCommType.add(lblNewLabel_1);

    comboBoxCommType = new JComboBox<String>();
    panelCommType.add(comboBoxCommType);
    comboBoxCommType
            .setModel(new DefaultComboBoxModel<String>(new String[] { "Global", "Topological", "Metric" }));
    comboBoxCommType.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            String item = (String) comboBoxCommType.getSelectedItem();
            if (item.equals("Topological")) {
                panelNearestNeighborCount.setVisible(true);
                panelMaxLocationRadius.setVisible(false);
            } else if (item.equals("Metric")) {
                panelNearestNeighborCount.setVisible(false);
                panelMaxLocationRadius.setVisible(true);
            } else if (item.equals("Global")) {
                panelNearestNeighborCount.setVisible(false);
                panelMaxLocationRadius.setVisible(false);
            }
        }
    });

    JPanel panelDestinationRadius = new JPanel();
    panelTab1.add(panelDestinationRadius);

    JLabel lblDestinationRadius = new JLabel("Destination Radius");
    panelDestinationRadius.add(lblDestinationRadius);

    frmtdtxtfldDestinationRadius = new JFormattedTextField(doubleFormat);
    frmtdtxtfldDestinationRadius.setColumns(4);
    frmtdtxtfldDestinationRadius.setValue((Number) 10);
    panelDestinationRadius.add(frmtdtxtfldDestinationRadius);

    JPanel panelResultsOutput = new JPanel();
    panelTab1.add(panelResultsOutput);

    JLabel lblResultsOutput = new JLabel("Results Output");
    panelResultsOutput.add(lblResultsOutput);

    final JCheckBox chckbxEskridge = new JCheckBox("Eskridge");
    panelResultsOutput.add(chckbxEskridge);

    final JCheckBox chckbxConflict = new JCheckBox("Conflict");
    panelResultsOutput.add(chckbxConflict);

    final JCheckBox chckbxPosition = new JCheckBox("Position");
    panelResultsOutput.add(chckbxPosition);

    final JCheckBox chckbxPredationResults = new JCheckBox("Predation");
    panelResultsOutput.add(chckbxPredationResults);

    JPanel panelMisc = new JPanel();
    panelTab1.add(panelMisc);

    JLabel lblNewLabel_3 = new JLabel("Misc");
    panelMisc.add(lblNewLabel_3);

    chckbxGraphical = new JCheckBox("Graphical?");
    chckbxGraphical.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (chckbxGraphical.isSelected()) {
                frmtdtxtfldRunCount.setValue((Number) 1);
                frmtdtxtfldRunCount.setEnabled(false);
                chckbxEskridge.setSelected(false);
                chckbxEskridge.setEnabled(false);
                String agentBuilder = (String) comboBoxAgentBuilder.getSelectedItem();
                if (agentBuilder.equals("Default")) {
                    comboBoxAgentBuilder.setSelectedIndex(1);
                }
            } else {
                chckbxEskridge.setEnabled(true);
                frmtdtxtfldRunCount.setEnabled(true);
            }
        }

    });
    panelMisc.add(chckbxGraphical);

    chckbxRandomSeed = new JCheckBox("Random Seed?");
    panelMisc.add(chckbxRandomSeed);

    chckbxPredationEnable = new JCheckBox("Predation?");
    chckbxPredationEnable.setSelected(true);
    chckbxPredationEnable.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (chckbxPredationEnable.isSelected()) {
                panelPredationStuff.setVisible(true);
                panelPredationBoxes.setVisible(true);
                panelPredationConstant.setVisible(true);
                panelNonMoversSurvive.setVisible(true);
            } else {
                panelPredationStuff.setVisible(false);
                panelPredationBoxes.setVisible(false);
                panelPredationConstant.setVisible(false);
                panelNonMoversSurvive.setVisible(false);
            }
        }
    });
    panelMisc.add(chckbxPredationEnable);

    JPanel panelCounts = new JPanel();
    panelTab1.add(panelCounts);

    JLabel lblNewLabel_4 = new JLabel("Run Count");
    panelCounts.add(lblNewLabel_4);

    frmtdtxtfldRunCount = new JFormattedTextField(countFormat);
    frmtdtxtfldRunCount.setToolTipText("The number of runs. Each run has a different random seed.");
    panelCounts.add(frmtdtxtfldRunCount);
    frmtdtxtfldRunCount.setColumns(4);
    frmtdtxtfldRunCount.setValue((Number) 1);

    JLabel lblNewLabel_5 = new JLabel("Sim Count");
    panelCounts.add(lblNewLabel_5);

    frmtdtxtfldSimCount = new JFormattedTextField(countFormat);
    frmtdtxtfldSimCount
            .setToolTipText("The number of simulations per run. Each simulation uses the same random seed.");
    frmtdtxtfldSimCount.setColumns(4);
    frmtdtxtfldSimCount.setValue((Number) 1);
    panelCounts.add(frmtdtxtfldSimCount);

    JLabel lblNewLabel_6 = new JLabel("Max Time Steps");
    panelCounts.add(lblNewLabel_6);

    frmtdtxtfldMaxTimeSteps = new JFormattedTextField(countFormat);
    frmtdtxtfldMaxTimeSteps.setToolTipText("The max number of time steps per simulation.");
    frmtdtxtfldMaxTimeSteps.setColumns(6);
    frmtdtxtfldMaxTimeSteps.setValue((Number) 20000);
    panelCounts.add(frmtdtxtfldMaxTimeSteps);

    ////////Panel tab 2

    JPanel panelTab2 = new JPanel();
    tabbedPane.addTab("Parameters", null, panelTab2, null);

    JPanel panelDecisionCalculator = new JPanel();
    panelTab2.add(panelDecisionCalculator);

    JLabel lblDecisionCalculator = new JLabel("Decision Calculator");
    panelDecisionCalculator.add(lblDecisionCalculator);

    final JComboBox<String> comboBoxDecisionCalculator = new JComboBox<String>();
    panelDecisionCalculator.add(comboBoxDecisionCalculator);
    comboBoxDecisionCalculator.setModel(
            new DefaultComboBoxModel<String>(new String[] { "Default", "Conflict", "Conflict Uninformed" }));

    JPanel panelAgentBuilder = new JPanel();
    panelTab2.add(panelAgentBuilder);

    JLabel lblAgentBuilder = new JLabel("Agent Builder");
    panelAgentBuilder.add(lblAgentBuilder);

    comboBoxAgentBuilder = new JComboBox<String>();
    panelAgentBuilder.add(comboBoxAgentBuilder);
    comboBoxAgentBuilder.setModel(new DefaultComboBoxModel<String>(new String[] { "Default", "Simple Angular",
            "Personality Simple Angular", "Simple Angular Uninformed" }));
    comboBoxAgentBuilder.setSelectedIndex(1);
    comboBoxAgentBuilder.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (chckbxGraphical.isSelected()) {
                String agentBuilder = (String) comboBoxAgentBuilder.getSelectedItem();
                if (agentBuilder.equals("Default")) {
                    comboBoxAgentBuilder.setSelectedIndex(1);
                }
            }
        }
    });

    JPanel panelModel = new JPanel();
    panelTab2.add(panelModel);

    JLabel lblModel = new JLabel("Model");
    panelModel.add(lblModel);

    comboBoxModel = new JComboBox<String>();
    panelModel.add(comboBoxModel);
    comboBoxModel.setModel(new DefaultComboBoxModel<String>(new String[] { "Sueur", "Gautrais" }));
    comboBoxModel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            String item = (String) comboBoxModel.getSelectedItem();
            if (item.equals("Sueur")) {
                panelSueurValues.setVisible(true);
                panelGautraisValues.setVisible(false);
            } else if (item.equals("Gautrais")) {
                panelSueurValues.setVisible(false);
                panelGautraisValues.setVisible(true);
            }
        }
    });

    JPanel panelEnvironment = new JPanel();
    panelTab2.add(panelEnvironment);

    JLabel lblEnvironment = new JLabel("Environment");
    panelEnvironment.add(lblEnvironment);

    comboBoxEnvironment = new JComboBox<String>();
    comboBoxEnvironment.setModel(
            new DefaultComboBoxModel<String>(new String[] { "Minimum", "Medium", "Maximum", "Uninformed" }));
    comboBoxEnvironment.setSelectedIndex(1);
    comboBoxEnvironment.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            String item = (String) comboBoxEnvironment.getSelectedItem();
            if (!item.equals("Uninformed")) {
                comboBoxDecisionCalculator.setEnabled(true);
                comboBoxAgentBuilder.setEnabled(true);
            }

            if (item.equals("Medium")) {
                panelAngle.setVisible(true);
                panelDistance.setVisible(true);
                panelPercentage.setVisible(true);
                panelNumberOfDestinations.setVisible(false);
                panelInformedCount.setVisible(false);
            } else if (item.equals("Minimum")) {
                panelAngle.setVisible(false);
                panelDistance.setVisible(false);
                panelPercentage.setVisible(true);
                panelNumberOfDestinations.setVisible(false);
                panelInformedCount.setVisible(false);
            } else if (item.equals("Maximum")) {
                panelAngle.setVisible(false);
                panelDistance.setVisible(false);
                panelPercentage.setVisible(true);
                panelNumberOfDestinations.setVisible(false);
                panelInformedCount.setVisible(false);
            } else if (item.equals("Uninformed")) {
                panelAngle.setVisible(true);
                panelDistance.setVisible(true);
                panelPercentage.setVisible(true);
                panelNumberOfDestinations.setVisible(false);
                panelInformedCount.setVisible(true);
                comboBoxDecisionCalculator.setSelectedIndex(2);
                comboBoxDecisionCalculator.setEnabled(false);
                comboBoxAgentBuilder.setSelectedIndex(3);
                comboBoxAgentBuilder.setEnabled(false);
            }
        }
    });
    panelEnvironment.add(comboBoxEnvironment);

    JPanel panelDefaultConflict = new JPanel();
    panelTab2.add(panelDefaultConflict);

    JLabel lblDefaultConflict = new JLabel("Default Conflict");
    panelDefaultConflict.add(lblDefaultConflict);

    final JSpinner spinnerDefaultConflict = new JSpinner();
    panelDefaultConflict.add(spinnerDefaultConflict);
    spinnerDefaultConflict.setModel(
            new SpinnerNumberModel(new Float(0.9f), new Float(0.1f), new Float(0.91f), new Float(0.05)));
    JFormattedTextField tfSpinnerConflict = ((JSpinner.DefaultEditor) spinnerDefaultConflict.getEditor())
            .getTextField();
    tfSpinnerConflict.setEditable(false);

    JPanel panelCancelationThreshold = new JPanel();
    panelTab2.add(panelCancelationThreshold);

    JLabel lblCancelationThreshold = new JLabel("Cancelation Threshold");
    panelCancelationThreshold.add(lblCancelationThreshold);

    final JSpinner spinnerCancelationThreshold = new JSpinner();
    panelCancelationThreshold.add(spinnerCancelationThreshold);
    spinnerCancelationThreshold.setModel(
            new SpinnerNumberModel(new Float(1.0f), new Float(0.0f), new Float(1.01f), new Float(0.05)));
    JFormattedTextField tfCancelationThreshold = ((JSpinner.DefaultEditor) spinnerCancelationThreshold
            .getEditor()).getTextField();
    tfCancelationThreshold.setEditable(false);

    JPanel panelStopAnywhere = new JPanel();
    panelTab2.add(panelStopAnywhere);

    final JCheckBox chckbxStopAnywhere = new JCheckBox("Stop Anywhere?");
    panelStopAnywhere.add(chckbxStopAnywhere);

    panelNearestNeighborCount = new JPanel();
    panelNearestNeighborCount.setVisible(false);
    panelTab2.add(panelNearestNeighborCount);

    JLabel lblNearestNeighborCount = new JLabel("Nearest Neighbor Count");
    panelNearestNeighborCount.add(lblNearestNeighborCount);

    frmtdtxtfldNearestNeighborCount = new JFormattedTextField(countFormat);
    panelNearestNeighborCount.add(frmtdtxtfldNearestNeighborCount);
    frmtdtxtfldNearestNeighborCount.setColumns(3);
    frmtdtxtfldNearestNeighborCount.setValue((Number) 10);

    panelMaxLocationRadius = new JPanel();
    panelMaxLocationRadius.setVisible(false);
    panelTab2.add(panelMaxLocationRadius);

    JLabel lblMaxLocationRadius = new JLabel("Max Location Radius");
    panelMaxLocationRadius.add(lblMaxLocationRadius);

    frmtdtxtfldMaxLocationRadius = new JFormattedTextField(doubleFormat);
    panelMaxLocationRadius.add(frmtdtxtfldMaxLocationRadius);
    frmtdtxtfldMaxLocationRadius.setColumns(5);
    frmtdtxtfldMaxLocationRadius.setValue((Number) 10.0);

    panelPredationBoxes = new JPanel();
    panelTab2.add(panelPredationBoxes);

    final JCheckBox chckbxUsePredationThreshold = new JCheckBox("Use Predation Threshold");
    panelPredationBoxes.add(chckbxUsePredationThreshold);

    final JCheckBox chckbxPopulationIndependent = new JCheckBox("Population Independent");
    chckbxPopulationIndependent.setSelected(true);
    panelPredationBoxes.add(chckbxPopulationIndependent);
    chckbxPopulationIndependent.setToolTipText(
            "Select this to allow predation to be independent of population size. Max predation for 10 agents will be the same as for 50 agents. ");

    panelPredationStuff = new JPanel();
    panelTab2.add(panelPredationStuff);

    JLabel lblPredationMinimum = new JLabel("Predation Minimum");
    panelPredationStuff.add(lblPredationMinimum);

    frmtdtxtfldPredationMinimum = new JFormattedTextField(doubleFormat);
    frmtdtxtfldPredationMinimum.setColumns(4);
    frmtdtxtfldPredationMinimum.setValue((Number) 0.0);
    panelPredationStuff.add(frmtdtxtfldPredationMinimum);

    JLabel lblPredationThreshold = new JLabel("Predation Threshold");
    panelPredationStuff.add(lblPredationThreshold);

    final JSpinner spinnerPredationThreshold = new JSpinner();
    panelPredationStuff.add(spinnerPredationThreshold);
    spinnerPredationThreshold.setModel(
            new SpinnerNumberModel(new Float(1.0f), new Float(0.0f), new Float(1.01f), new Float(0.05)));
    JFormattedTextField tfPredationThreshold = ((JSpinner.DefaultEditor) spinnerPredationThreshold.getEditor())
            .getTextField();
    tfPredationThreshold.setEditable(false);

    JLabel lblMaxEaten = new JLabel("Max Eaten");
    panelPredationStuff.add(lblMaxEaten);

    spinnerMaxEaten = new JSpinner();
    spinnerMaxEaten.setToolTipText("The max number eaten per time step.");
    panelPredationStuff.add(spinnerMaxEaten);
    spinnerMaxEaten.setModel(new SpinnerNumberModel(new Integer(10), new Integer(0),
            new Integer(sliderAgent.getValue()), new Integer(1)));
    JFormattedTextField tfMaxEaten = ((JSpinner.DefaultEditor) spinnerMaxEaten.getEditor()).getTextField();
    tfMaxEaten.setEditable(false);

    panelPredationConstant = new JPanel();
    panelTab2.add(panelPredationConstant);

    JLabel lblPredationConstant = new JLabel("Predation Constant");
    panelPredationConstant.add(lblPredationConstant);

    frmtdtxtfldPredationConstant = new JFormattedTextField(doubleFormat);
    panelPredationConstant.add(frmtdtxtfldPredationConstant);
    frmtdtxtfldPredationConstant.setToolTipText("Value should be positive. Recommended values are near 0.001");
    frmtdtxtfldPredationConstant.setColumns(4);
    frmtdtxtfldPredationConstant.setValue((Number) 0.001);

    panelNonMoversSurvive = new JPanel();
    panelTab2.add(panelNonMoversSurvive);

    final JCheckBox chckbxNonMoversSurvive = new JCheckBox("Non-movers Survive?");
    chckbxNonMoversSurvive.setSelected(false);
    panelNonMoversSurvive.add(chckbxNonMoversSurvive);

    ////////Tab 3

    JPanel panelTab3 = new JPanel();
    tabbedPane.addTab("Environment", null, panelTab3, null);
    panelTab3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    panelSueurValues = new JPanel();
    panelTab3.add(panelSueurValues);
    panelSueurValues.setLayout(new BoxLayout(panelSueurValues, BoxLayout.Y_AXIS));

    JLabel lblSueurValues = new JLabel("Sueur Values");
    lblSueurValues.setHorizontalAlignment(SwingConstants.TRAILING);
    lblSueurValues.setAlignmentX(Component.CENTER_ALIGNMENT);
    panelSueurValues.add(lblSueurValues);

    JPanel panelAlpha = new JPanel();
    FlowLayout flowLayout = (FlowLayout) panelAlpha.getLayout();
    flowLayout.setAlignment(FlowLayout.RIGHT);
    panelSueurValues.add(panelAlpha);

    JLabel lblAlpha = new JLabel("alpha");
    lblAlpha.setHorizontalAlignment(SwingConstants.CENTER);
    panelAlpha.add(lblAlpha);

    final JFormattedTextField frmtdtxtfldAlpha = new JFormattedTextField(doubleFormat);
    frmtdtxtfldAlpha.setHorizontalAlignment(SwingConstants.TRAILING);
    lblAlpha.setLabelFor(frmtdtxtfldAlpha);
    panelAlpha.add(frmtdtxtfldAlpha);
    frmtdtxtfldAlpha.setColumns(6);
    frmtdtxtfldAlpha.setValue((Number) 0.006161429);

    JPanel panelAlphaC = new JPanel();
    FlowLayout flowLayout_2 = (FlowLayout) panelAlphaC.getLayout();
    flowLayout_2.setAlignment(FlowLayout.RIGHT);
    panelSueurValues.add(panelAlphaC);

    JLabel lblAlphaC = new JLabel("alpha c");
    panelAlphaC.add(lblAlphaC);

    final JFormattedTextField frmtdtxtfldAlphaC = new JFormattedTextField(doubleFormat);
    frmtdtxtfldAlphaC.setHorizontalAlignment(SwingConstants.TRAILING);
    lblAlphaC.setLabelFor(frmtdtxtfldAlphaC);
    panelAlphaC.add(frmtdtxtfldAlphaC);
    frmtdtxtfldAlphaC.setColumns(6);
    frmtdtxtfldAlphaC.setValue((Number) 0.009);

    JPanel panelBeta = new JPanel();
    FlowLayout flowLayout_1 = (FlowLayout) panelBeta.getLayout();
    flowLayout_1.setAlignment(FlowLayout.RIGHT);
    panelSueurValues.add(panelBeta);

    JLabel lblBeta = new JLabel("beta");
    panelBeta.add(lblBeta);

    final JFormattedTextField frmtdtxtfldBeta = new JFormattedTextField(doubleFormat);
    frmtdtxtfldBeta.setHorizontalAlignment(SwingConstants.TRAILING);
    panelBeta.add(frmtdtxtfldBeta);
    frmtdtxtfldBeta.setColumns(6);
    frmtdtxtfldBeta.setValue((Number) 0.013422819);

    JPanel panelBetaC = new JPanel();
    FlowLayout flowLayout_14 = (FlowLayout) panelBetaC.getLayout();
    flowLayout_14.setAlignment(FlowLayout.RIGHT);
    panelSueurValues.add(panelBetaC);

    JLabel lblBetaC = new JLabel("beta c");
    panelBetaC.add(lblBetaC);

    final JFormattedTextField frmtdtxtfldBetaC = new JFormattedTextField(doubleFormat);
    frmtdtxtfldBetaC.setHorizontalAlignment(SwingConstants.TRAILING);
    panelBetaC.add(frmtdtxtfldBetaC);
    frmtdtxtfldBetaC.setColumns(6);
    frmtdtxtfldBetaC.setValue((Number) (-0.009));

    JPanel panelS = new JPanel();
    FlowLayout flowLayout_3 = (FlowLayout) panelS.getLayout();
    flowLayout_3.setAlignment(FlowLayout.RIGHT);
    panelSueurValues.add(panelS);

    JLabel lblS = new JLabel("S");
    panelS.add(lblS);

    final JFormattedTextField frmtdtxtfldS = new JFormattedTextField(countFormat);
    frmtdtxtfldS.setHorizontalAlignment(SwingConstants.TRAILING);
    panelS.add(frmtdtxtfldS);
    frmtdtxtfldS.setColumns(6);
    frmtdtxtfldS.setValue((Number) 2);

    JPanel panelQ = new JPanel();
    FlowLayout flowLayout_4 = (FlowLayout) panelQ.getLayout();
    flowLayout_4.setAlignment(FlowLayout.RIGHT);
    panelSueurValues.add(panelQ);

    JLabel lblQ = new JLabel("q");
    panelQ.add(lblQ);

    final JFormattedTextField frmtdtxtfldQ = new JFormattedTextField(doubleFormat);
    frmtdtxtfldQ.setHorizontalAlignment(SwingConstants.TRAILING);
    panelQ.add(frmtdtxtfldQ);
    frmtdtxtfldQ.setColumns(6);
    frmtdtxtfldQ.setValue((Number) 2.3);

    panelGautraisValues = new JPanel();
    panelGautraisValues.setVisible(false);
    panelTab3.add(panelGautraisValues);
    panelGautraisValues.setLayout(new BoxLayout(panelGautraisValues, BoxLayout.Y_AXIS));

    JLabel label = new JLabel("Gautrais Values");
    label.setAlignmentX(Component.CENTER_ALIGNMENT);
    panelGautraisValues.add(label);

    JPanel panelTauO = new JPanel();
    FlowLayout flowLayout_5 = (FlowLayout) panelTauO.getLayout();
    flowLayout_5.setAlignment(FlowLayout.RIGHT);
    panelGautraisValues.add(panelTauO);

    JLabel lblTauO = new JLabel("tau o");
    panelTauO.add(lblTauO);

    final JFormattedTextField frmtdtxtfldTaoO = new JFormattedTextField(doubleFormat);
    frmtdtxtfldTaoO.setHorizontalAlignment(SwingConstants.TRAILING);
    panelTauO.add(frmtdtxtfldTaoO);
    frmtdtxtfldTaoO.setColumns(4);
    frmtdtxtfldTaoO.setValue((Number) 1290);

    JPanel panelGammaC = new JPanel();
    FlowLayout flowLayout_6 = (FlowLayout) panelGammaC.getLayout();
    flowLayout_6.setAlignment(FlowLayout.RIGHT);
    panelGautraisValues.add(panelGammaC);

    JLabel lblGammaC = new JLabel("gamma c");
    panelGammaC.add(lblGammaC);

    final JFormattedTextField frmtdtxtfldGammaC = new JFormattedTextField(doubleFormat);
    frmtdtxtfldGammaC.setHorizontalAlignment(SwingConstants.TRAILING);
    panelGammaC.add(frmtdtxtfldGammaC);
    frmtdtxtfldGammaC.setColumns(4);
    frmtdtxtfldGammaC.setValue((Number) 2.0);

    JPanel panelEpsilonC = new JPanel();
    FlowLayout flowLayout_7 = (FlowLayout) panelEpsilonC.getLayout();
    flowLayout_7.setAlignment(FlowLayout.RIGHT);
    panelGautraisValues.add(panelEpsilonC);

    JLabel lblEpsilonC = new JLabel("epsilon c");
    panelEpsilonC.add(lblEpsilonC);

    final JFormattedTextField frmtdtxtfldEpsilonC = new JFormattedTextField(doubleFormat);
    frmtdtxtfldEpsilonC.setHorizontalAlignment(SwingConstants.TRAILING);
    panelEpsilonC.add(frmtdtxtfldEpsilonC);
    frmtdtxtfldEpsilonC.setColumns(4);
    frmtdtxtfldEpsilonC.setValue((Number) 2.3);

    JPanel panelAlphaF = new JPanel();
    FlowLayout flowLayout_8 = (FlowLayout) panelAlphaF.getLayout();
    flowLayout_8.setAlignment(FlowLayout.RIGHT);
    panelGautraisValues.add(panelAlphaF);

    JLabel lblAlphaF = new JLabel("alpha f");
    panelAlphaF.add(lblAlphaF);

    final JFormattedTextField frmtdtxtfldAlphaF = new JFormattedTextField(doubleFormat);
    frmtdtxtfldAlphaF.setHorizontalAlignment(SwingConstants.TRAILING);
    panelAlphaF.add(frmtdtxtfldAlphaF);
    frmtdtxtfldAlphaF.setColumns(4);
    frmtdtxtfldAlphaF.setValue((Number) 162.3);

    JPanel panelBetaF = new JPanel();
    FlowLayout flowLayout_9 = (FlowLayout) panelBetaF.getLayout();
    flowLayout_9.setAlignment(FlowLayout.RIGHT);
    panelGautraisValues.add(panelBetaF);

    JLabel lblBetaF = new JLabel("beta f");
    panelBetaF.add(lblBetaF);

    final JFormattedTextField frmtdtxtfldBetaF = new JFormattedTextField(doubleFormat);
    frmtdtxtfldBetaF.setHorizontalAlignment(SwingConstants.TRAILING);
    panelBetaF.add(frmtdtxtfldBetaF);
    frmtdtxtfldBetaF.setColumns(4);
    frmtdtxtfldBetaF.setValue((Number) 75.4);

    JPanel panelEnvironmentVariables = new JPanel();
    panelTab3.add(panelEnvironmentVariables);
    panelEnvironmentVariables.setLayout(new BoxLayout(panelEnvironmentVariables, BoxLayout.Y_AXIS));

    JLabel lblEnvironmentVariables = new JLabel("Environment Variables");
    lblEnvironmentVariables.setAlignmentX(Component.CENTER_ALIGNMENT);
    panelEnvironmentVariables.add(lblEnvironmentVariables);

    panelAngle = new JPanel();
    FlowLayout flowLayout_10 = (FlowLayout) panelAngle.getLayout();
    flowLayout_10.setAlignment(FlowLayout.RIGHT);
    panelEnvironmentVariables.add(panelAngle);

    JLabel lblAngle = new JLabel("Angle");
    panelAngle.add(lblAngle);

    final JFormattedTextField frmtdtxtfldAngle = new JFormattedTextField(doubleFormat);
    frmtdtxtfldAngle.setHorizontalAlignment(SwingConstants.TRAILING);
    frmtdtxtfldAngle.setToolTipText("Angle between destinations");
    panelAngle.add(frmtdtxtfldAngle);
    frmtdtxtfldAngle.setColumns(3);
    frmtdtxtfldAngle.setValue((Number) 72.00);

    panelNumberOfDestinations = new JPanel();
    FlowLayout flowLayout_13 = (FlowLayout) panelNumberOfDestinations.getLayout();
    flowLayout_13.setAlignment(FlowLayout.RIGHT);
    panelNumberOfDestinations.setVisible(false);
    panelEnvironmentVariables.add(panelNumberOfDestinations);

    JLabel lblNumberOfDestinations = new JLabel("Number of Destinations");
    panelNumberOfDestinations.add(lblNumberOfDestinations);

    JFormattedTextField frmtdtxtfldNumberOfDestinations = new JFormattedTextField(countFormat);
    frmtdtxtfldNumberOfDestinations.setHorizontalAlignment(SwingConstants.TRAILING);
    panelNumberOfDestinations.add(frmtdtxtfldNumberOfDestinations);
    frmtdtxtfldNumberOfDestinations.setColumns(3);
    frmtdtxtfldNumberOfDestinations.setValue((Number) 2);

    panelDistance = new JPanel();
    FlowLayout flowLayout_11 = (FlowLayout) panelDistance.getLayout();
    flowLayout_11.setAlignment(FlowLayout.RIGHT);
    panelEnvironmentVariables.add(panelDistance);

    JLabel lblDistance = new JLabel("Distance");
    panelDistance.add(lblDistance);

    frmtdtxtfldDistance = new JFormattedTextField(doubleFormat);
    frmtdtxtfldDistance.setHorizontalAlignment(SwingConstants.TRAILING);
    frmtdtxtfldDistance.setToolTipText("Distance the destination is from origin (0,0)");
    panelDistance.add(frmtdtxtfldDistance);
    frmtdtxtfldDistance.setColumns(3);
    frmtdtxtfldDistance.setValue((Number) 150.0);

    panelPercentage = new JPanel();
    FlowLayout flowLayout_12 = (FlowLayout) panelPercentage.getLayout();
    flowLayout_12.setAlignment(FlowLayout.RIGHT);
    panelEnvironmentVariables.add(panelPercentage);

    JLabel lblPercentage = new JLabel("Percentage");
    panelPercentage.add(lblPercentage);

    frmtdtxtfldPercentage = new JFormattedTextField(doubleFormat);
    frmtdtxtfldPercentage.setHorizontalAlignment(SwingConstants.TRAILING);
    frmtdtxtfldPercentage.setToolTipText(
            "The percentage moving to one of the two destinations ( The other gets 1 - percentage).");
    panelPercentage.add(frmtdtxtfldPercentage);
    frmtdtxtfldPercentage.setColumns(3);
    frmtdtxtfldPercentage.setValue((Number) 0.500);

    panelInformedCount = new JPanel();
    panelEnvironmentVariables.add(panelInformedCount);

    JLabel lblInformedCount = new JLabel("Informed Count");
    panelInformedCount.add(lblInformedCount);

    final JFormattedTextField frmtdtxtfldInformedCount = new JFormattedTextField(countFormat);
    frmtdtxtfldInformedCount.setHorizontalAlignment(SwingConstants.TRAILING);
    frmtdtxtfldInformedCount.setColumns(3);
    frmtdtxtfldInformedCount.setToolTipText(
            "The number of agents moving toward a preferred destination. This number is duplicated on the southern pole as well.");
    frmtdtxtfldInformedCount.setValue((Number) 4);
    panelInformedCount.setVisible(false);

    panelInformedCount.add(frmtdtxtfldInformedCount);

    JPanel panelStartButtons = new JPanel();

    JButton btnStartSimulation = new JButton("Create Simulator Instance");
    btnStartSimulation.setToolTipText("Creates a new simulator instance from the settings provided.");
    btnStartSimulation.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isReady = true;
            ErrorPacketContainer errorPacketContainer = new ErrorPacketContainer();

            if (jframeErrorMessages != null && jframeErrorMessages.isVisible()) {
                jframeErrorMessages.dispose();
            }

            frmtdtxtfldRunCount.setBackground(Color.WHITE);
            frmtdtxtfldSimCount.setBackground(Color.WHITE);
            frmtdtxtfldMaxTimeSteps.setBackground(Color.WHITE);
            frmtdtxtfldPredationMinimum.setBackground(Color.WHITE);
            frmtdtxtfldPredationConstant.setBackground(Color.WHITE);
            frmtdtxtfldNearestNeighborCount.setBackground(Color.WHITE);
            frmtdtxtfldMaxLocationRadius.setBackground(Color.WHITE);
            frmtdtxtfldPercentage.setBackground(Color.WHITE);
            frmtdtxtfldDistance.setBackground(Color.WHITE);
            frmtdtxtfldDestinationRadius.setBackground(Color.WHITE);
            frmtdtxtfldAngle.setBackground(Color.WHITE);
            frmtdtxtfldInformedCount.setBackground(Color.WHITE);

            StringBuilder errorMessages = new StringBuilder();

            if (((Number) frmtdtxtfldRunCount.getValue()).intValue() <= 0) {
                errorMessages.append("Run Count must be positive\n");
                frmtdtxtfldRunCount.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Run Count must be positive", frmtdtxtfldRunCount, 0);
                isReady = false;
            }
            if (((Number) frmtdtxtfldSimCount.getValue()).intValue() <= 0) {
                errorMessages.append("Sim Count must be positive\n");
                frmtdtxtfldSimCount.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Sim Count must be positive", frmtdtxtfldSimCount, 0);
                isReady = false;
            }
            if (((Number) frmtdtxtfldMaxTimeSteps.getValue()).intValue() <= 0) {
                errorMessages.append("Max Time Steps must be positive\n");
                frmtdtxtfldMaxTimeSteps.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Max Time Steps must be positive", frmtdtxtfldMaxTimeSteps, 0);
                isReady = false;
            }
            if (((Number) frmtdtxtfldPredationMinimum.getValue()).doubleValue() < 0
                    && chckbxPredationEnable.isSelected()) {
                errorMessages.append("Predation Minimum must be positive\n");
                frmtdtxtfldPredationMinimum.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Predation Minimum must be positive",
                        frmtdtxtfldPredationMinimum, 1);
                isReady = false;
            }
            if (((Number) frmtdtxtfldPredationConstant.getValue()).doubleValue() <= 0
                    && chckbxPredationEnable.isSelected()) {
                errorMessages.append("Predation Constant must be positive\n");
                frmtdtxtfldPredationConstant.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Predation Constant must be positive",
                        frmtdtxtfldPredationConstant, 1);
                isReady = false;
            }
            if (((Number) frmtdtxtfldNearestNeighborCount.getValue()).intValue() < 0
                    && panelNearestNeighborCount.isVisible()) {
                errorMessages.append("Nearest Neighbor Count must be positive\n");
                frmtdtxtfldNearestNeighborCount.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Nearest Neighbor Count must be positive",
                        frmtdtxtfldNearestNeighborCount, 1);
                isReady = false;
            }
            if (((Number) frmtdtxtfldMaxLocationRadius.getValue()).doubleValue() < 0
                    && panelMaxLocationRadius.isVisible()) {
                errorMessages.append("Max Location Radius must be positive\n");
                frmtdtxtfldMaxLocationRadius.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Max Location Radius must be positive",
                        frmtdtxtfldMaxLocationRadius, 1);
                isReady = false;
            }
            if ((((Number) frmtdtxtfldPercentage.getValue()).doubleValue() < 0.0
                    || ((Number) frmtdtxtfldPercentage.getValue()).doubleValue() > 1.0)
                    && panelPercentage.isVisible()) {
                errorMessages.append(
                        "Percentage needs to be greater than or equal to 0 and less than or equal to 1\n");
                frmtdtxtfldPercentage.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket(
                        "Percentage needs to be greater than or equal to 0 and less than or equal to 1",
                        frmtdtxtfldPercentage, 2);
                isReady = false;
            }
            if (((Number) frmtdtxtfldDistance.getValue()).doubleValue() <= 0
                    && frmtdtxtfldDistance.isVisible()) {
                errorMessages.append("Distance must be positive\n");
                frmtdtxtfldDistance.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Distance must be positive", frmtdtxtfldDistance, 2);
                isReady = false;
            }
            if (((Number) frmtdtxtfldDestinationRadius.getValue()).doubleValue() <= 0) {
                errorMessages.append("Destination Radius must be positive\n");
                frmtdtxtfldDestinationRadius.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Destination Radius must be positive",
                        frmtdtxtfldDestinationRadius, 0);
                isReady = false;
            }
            if (((Number) frmtdtxtfldAngle.getValue()).doubleValue() < 0) {
                errorMessages.append("Angle must be positive or zero\n");
                frmtdtxtfldAngle.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Angle must be positive", frmtdtxtfldAngle, 2);
                isReady = false;
            }
            if (((Number) frmtdtxtfldInformedCount.getValue()).intValue() <= 0) {
                errorMessages.append("Informed Count must be positive\n");
                frmtdtxtfldInformedCount.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket("Informed Count must be positive", frmtdtxtfldInformedCount, 2);
                isReady = false;
            } else if (((Number) frmtdtxtfldInformedCount.getValue()).intValue() * 2 > sliderAgent.getValue()) {
                errorMessages.append("Informed Count should at most be half the count of total agents\n");
                frmtdtxtfldInformedCount.setBackground(Color.YELLOW);
                errorPacketContainer.addPacket(
                        "Informed Count should at most be half the count of total agents",
                        frmtdtxtfldInformedCount, 2);
                isReady = false;
            }

            if (!isReady) {
                jframeErrorMessages = createJFrameErrorMessages(errorPacketContainer, tabbedPane);
                jframeErrorMessages.setVisible(true);
            } else {
                _simulatorProperties = new Properties();

                _simulatorProperties.put("run-count", String.valueOf(frmtdtxtfldRunCount.getValue()));
                _simulatorProperties.put("simulation-count", String.valueOf(frmtdtxtfldSimCount.getValue()));
                _simulatorProperties.put("max-simulation-time-steps",
                        String.valueOf(frmtdtxtfldMaxTimeSteps.getValue()));
                _simulatorProperties.put("random-seed", String.valueOf(1)); // Doesn't change
                _simulatorProperties.put("individual-count", String.valueOf(sliderAgent.getValue()));
                _simulatorProperties.put("run-graphical", String.valueOf(chckbxGraphical.isSelected()));
                _simulatorProperties.put("pre-calculate-probabilities", String.valueOf(false)); // Doesn't change
                _simulatorProperties.put("use-random-random-seed",
                        String.valueOf(chckbxRandomSeed.isSelected()));
                _simulatorProperties.put("can-multiple-initiate", String.valueOf(true)); // Doesn't change

                _simulatorProperties.put("eskridge-results", String.valueOf(chckbxEskridge.isSelected()));
                _simulatorProperties.put("conflict-results", String.valueOf(chckbxConflict.isSelected()));
                _simulatorProperties.put("position-results", String.valueOf(chckbxPosition.isSelected()));
                _simulatorProperties.put("predation-results",
                        String.valueOf(chckbxPredationResults.isSelected()));

                _simulatorProperties.put("communication-type",
                        String.valueOf(comboBoxCommType.getSelectedItem()).toLowerCase());

                _simulatorProperties.put("nearest-neighbor-count",
                        String.valueOf(frmtdtxtfldNearestNeighborCount.getValue()));
                _simulatorProperties.put("max-location-radius",
                        String.valueOf(frmtdtxtfldMaxLocationRadius.getValue()));

                _simulatorProperties.put("destination-size-radius",
                        String.valueOf(frmtdtxtfldDestinationRadius.getValue()));

                _simulatorProperties.put("max-agents-eaten-per-step",
                        String.valueOf(spinnerMaxEaten.getValue()));
                _simulatorProperties.put("enable-predator", String.valueOf(chckbxPredationEnable.isSelected()));
                _simulatorProperties.put("predation-probability-minimum",
                        String.valueOf(frmtdtxtfldPredationMinimum.getValue()));
                _simulatorProperties.put("predation-multiplier",
                        String.valueOf(frmtdtxtfldPredationConstant.getValue()));
                _simulatorProperties.put("use-predation-threshold",
                        String.valueOf(chckbxUsePredationThreshold.isSelected()));
                _simulatorProperties.put("predation-threshold",
                        String.valueOf(spinnerPredationThreshold.getValue()));
                _simulatorProperties.put("predation-by-population",
                        String.valueOf(chckbxPopulationIndependent.isSelected()));
                _simulatorProperties.put("count-non-movers-as-survivors",
                        String.valueOf(chckbxNonMoversSurvive.isSelected()));

                _simulatorProperties.put("stop-at-any-destination",
                        String.valueOf(chckbxStopAnywhere.isSelected()));

                _simulatorProperties.put("adhesion-time-limit",
                        String.valueOf(frmtdtxtfldMaxTimeSteps.getValue()));

                _simulatorProperties.put("alpha", String.valueOf(frmtdtxtfldAlpha.getValue()));
                _simulatorProperties.put("alpha-c", String.valueOf(frmtdtxtfldAlphaC.getValue()));
                _simulatorProperties.put("beta", String.valueOf(frmtdtxtfldBeta.getValue()));
                _simulatorProperties.put("beta-c", String.valueOf(frmtdtxtfldBetaC.getValue()));
                _simulatorProperties.put("S", String.valueOf(frmtdtxtfldS.getValue()));
                _simulatorProperties.put("q", String.valueOf(frmtdtxtfldQ.getValue()));

                _simulatorProperties.put("lambda", String.valueOf(0.2));

                _simulatorProperties.put("tau-o", String.valueOf(frmtdtxtfldTaoO.getValue()));
                _simulatorProperties.put("gamma-c", String.valueOf(frmtdtxtfldGammaC.getValue()));
                _simulatorProperties.put("epsilon-c", String.valueOf(frmtdtxtfldEpsilonC.getValue()));
                _simulatorProperties.put("alpha-f", String.valueOf(frmtdtxtfldAlphaF.getValue()));
                _simulatorProperties.put("beta-f", String.valueOf(frmtdtxtfldBetaF.getValue()));

                _simulatorProperties.put("default-conflict-value",
                        String.valueOf(spinnerDefaultConflict.getValue()));

                _simulatorProperties.put("cancellation-threshold",
                        String.valueOf(spinnerCancelationThreshold.getValue()));
                StringBuilder sbAgentBuilder = new StringBuilder();
                sbAgentBuilder.append("edu.snu.leader.discrete.simulator.Sueur");
                sbAgentBuilder.append(comboBoxAgentBuilder.getSelectedItem().toString().replace(" ", ""));
                sbAgentBuilder.append("AgentBuilder");
                _simulatorProperties.put("agent-builder", String.valueOf(sbAgentBuilder.toString()));

                StringBuilder sbDecisionCalculator = new StringBuilder();
                sbDecisionCalculator.append("edu.snu.leader.discrete.simulator.");
                sbDecisionCalculator.append(comboBoxModel.getSelectedItem());
                //                    sbDecisionCalculator.append(comboBoxDecisionCalculator.getSelectedItem());
                sbDecisionCalculator
                        .append(comboBoxDecisionCalculator.getSelectedItem().toString().replace(" ", ""));
                sbDecisionCalculator.append("DecisionCalculator");
                _simulatorProperties.put("decision-calculator",
                        String.valueOf(sbDecisionCalculator.toString()));

                StringBuilder sbLocationsFile = new StringBuilder();
                sbLocationsFile.append("cfg/sim/locations/metric/valid-metric-loc-");
                sbLocationsFile.append(String.format("%03d", sliderAgent.getValue()));
                sbLocationsFile.append("-seed-00001.dat");
                _simulatorProperties.put("locations-file", String.valueOf(sbLocationsFile.toString()));

                //create destination file
                DestinationBuilder db = new DestinationBuilder(sliderAgent.getValue(), 1L);

                StringBuilder sbDestinationsFile = new StringBuilder();
                sbDestinationsFile.append("cfg/sim/destinations/destinations-");
                switch (comboBoxEnvironment.getSelectedItem().toString()) {
                case ("Minimum"):
                    sbDestinationsFile.append("diffdis-" + sliderAgent.getValue());
                    sbDestinationsFile.append("-per-" + frmtdtxtfldPercentage.getValue());
                    sbDestinationsFile.append("-seed-1.dat");
                    db.generateDifferentDistance(((Number) frmtdtxtfldPercentage.getValue()).doubleValue(), 200,
                            100, 75);
                    break;
                case ("Medium"):
                    sbDestinationsFile.append("split-" + sliderAgent.getValue());
                    sbDestinationsFile.append("-dis-" + frmtdtxtfldDistance.getValue());
                    sbDestinationsFile.append("-ang-"
                            + String.format("%.2f", ((Number) frmtdtxtfldAngle.getValue()).doubleValue()));
                    sbDestinationsFile.append("-per-"
                            + String.format("%.3f", ((Number) frmtdtxtfldPercentage.getValue()).doubleValue()));
                    sbDestinationsFile.append("-seed-1.dat");
                    db.generateSplitNorth(((Number) frmtdtxtfldDistance.getValue()).doubleValue(),
                            ((Number) frmtdtxtfldAngle.getValue()).doubleValue(),
                            ((Number) frmtdtxtfldPercentage.getValue()).doubleValue());
                    break;
                case ("Maximum"):
                    sbDestinationsFile.append("poles-" + sliderAgent.getValue());
                    sbDestinationsFile.append("-per-" + frmtdtxtfldPercentage.getValue());
                    sbDestinationsFile.append("-seed-1.dat");
                    db.generatePoles(50, 100, ((Number) frmtdtxtfldPercentage.getValue()).doubleValue());
                    break;
                case ("Uninformed"):
                    sbDestinationsFile.append("split-poles-" + frmtdtxtfldInformedCount.getValue());
                    sbDestinationsFile.append("-dis-"
                            + String.format("%.1f", ((Number) frmtdtxtfldDistance.getValue()).doubleValue()));
                    sbDestinationsFile.append("-ang-"
                            + String.format("%.2f", ((Number) frmtdtxtfldAngle.getValue()).doubleValue()));
                    sbDestinationsFile.append("-per-"
                            + String.format("%.3f", ((Number) frmtdtxtfldPercentage.getValue()).doubleValue()));
                    sbDestinationsFile.append("-seed-1.dat");
                    db.generateSplitPoles(((Number) frmtdtxtfldDistance.getValue()).doubleValue(),
                            ((Number) frmtdtxtfldAngle.getValue()).doubleValue(),
                            ((Number) frmtdtxtfldPercentage.getValue()).doubleValue(),
                            ((Number) frmtdtxtfldInformedCount.getValue()).intValue());
                    break;
                default: //Should never happen
                    break;
                }
                _simulatorProperties.put("destinations-file", String.valueOf(sbDestinationsFile.toString()));

                _simulatorProperties.put("live-delay", String.valueOf(15)); //Doesn't change
                _simulatorProperties.put("results-dir", "results"); //Doesn't change

                new Thread(new Runnable() {
                    public void run() {
                        try {
                            runSimulation();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }).start();
            }
        }

    });
    panelStartButtons.add(btnStartSimulation);

    JButton btnStartSimulationFrom = new JButton("Run Simulation from Properties File");
    btnStartSimulationFrom
            .setToolTipText("Runs the simulator with the values provided in the properties file.");
    btnStartSimulationFrom.setEnabled(false);
    panelStartButtons.add(btnStartSimulationFrom);

    panelTab3.add(panelStartButtons);
}

From source file:edu.mit.fss.examples.gui.ExecutionControlPanel.java

/**
 * Instantiates a new execution control panel.
 *//*from   w ww.  ja  va 2s  .  c  om*/
public ExecutionControlPanel() {
    initializeAction.putValue(Action.SHORT_DESCRIPTION, "Initialize the execution.");
    initializeAction.setEnabled(false);
    runAction.putValue(Action.SHORT_DESCRIPTION, "Run the execution.");
    runAction.setEnabled(false);
    stopAction.putValue(Action.SHORT_DESCRIPTION, "Stop the execution.");
    stopAction.setEnabled(false);
    terminateAction.putValue(Action.SHORT_DESCRIPTION, "Terminate the execution.");
    terminateAction.setEnabled(false);

    setLayout(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());

    buttonPanel.add(new JButton(initializeAction));
    buttonPanel.add(new JButton(runAction));
    buttonPanel.add(new JButton(stopAction));
    buttonPanel.add(new JButton(terminateAction));

    timeStepField = new JFormattedTextField(NumberFormat.getNumberInstance());
    timeStepField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void changedUpdate(DocumentEvent e) {
            checkUpdate();
        }

        private void checkUpdate() {
            long unitConversion = getTimeStepUnits();
            long timeStep = FastMath.round(unitConversion * ((Number) timeStepField.getValue()).doubleValue());
            setTimeStepAction.setEnabled(timeStep != federate.getTimeStep());
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            checkUpdate();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            checkUpdate();
        }
    });
    timeStepField.setColumns(4);
    buttonPanel.add(new JLabel("Time Step: "));
    buttonPanel.add(timeStepField);
    timeStepUnits.setSelectedItem(TimeUnit.SECONDS);
    buttonPanel.add(timeStepUnits);
    timeStepUnits.addActionListener(new ActionListener() {
        private long lastUnitConversion = getTimeStepUnits();

        @Override
        public void actionPerformed(ActionEvent e) {
            long unitConversion = getTimeStepUnits();
            // update field value using new units
            timeStepField.setValue(((Double) timeStepField.getValue()) * lastUnitConversion / unitConversion);
            // update stored value
            lastUnitConversion = unitConversion;
        }
    });
    buttonPanel.add(new JButton(setTimeStepAction));

    buttonPanel.add(new JLabel("Min. Step Duration"));
    stepDurationField = new JFormattedTextField(NumberFormat.getNumberInstance());
    stepDurationField.setColumns(4);
    stepDurationField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void changedUpdate(DocumentEvent e) {
            checkUpdate();
        }

        private void checkUpdate() {
            long unitConversion = getStepDurationUnits();
            long minStepDuration = FastMath
                    .round(unitConversion * ((Number) stepDurationField.getValue()).doubleValue());
            setMinStepDurationAction.setEnabled(minStepDuration != federate.getMinimumStepDuration());
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            checkUpdate();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            checkUpdate();
        }
    });
    buttonPanel.add(stepDurationField);
    stepDurationUnits.setSelectedItem(TimeUnit.MILLISECONDS);
    buttonPanel.add(stepDurationUnits);
    stepDurationUnits.addActionListener(new ActionListener() {
        private long lastUnitConversion = getStepDurationUnits();

        @Override
        public void actionPerformed(ActionEvent e) {
            long unitConversion = getStepDurationUnits();
            // update field value using new units
            stepDurationField
                    .setValue(((Double) stepDurationField.getValue()) * lastUnitConversion / unitConversion);
            // update stored value
            lastUnitConversion = unitConversion;
        }
    });
    buttonPanel.add(new JButton(setMinStepDurationAction));

    add(buttonPanel, BorderLayout.CENTER);
}

From source file:org.angnysa.yaba.swing.BudgetFrame.java

private void buildSimulationPanel() {

    simulationPanel = new JPanel();
    SpringLayout springLayout = new SpringLayout();
    simulationPanel.setLayout(springLayout);

    // chart data
    simulationDataset = new SimulationDataset(service);
    simulationDataset.setInitial(0D);/* w ww . j  a  v a2 s  . c  o  m*/
    simulationDataset.setStart(new LocalDate());
    simulationDataset.setEnd(new LocalDate().plus(Years.ONE));
    simulationDataset.setPeriod(Period.months(1));
    simulationDataset.updateDataset();
    transactionModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            simulationDataset.updateDataset();
        }
    });
    reconciliationModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            simulationDataset.updateDataset();
        }
    });

    // initial amount label
    JLabel amountLbl = new JLabel(Messages.getString("simulation.field.initial-amount")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, amountLbl, 10, SpringLayout.WEST, simulationPanel);
    simulationPanel.add(amountLbl);

    // initial amount field
    amountFld = new JFormattedTextField(
            new DefaultFormatterFactory(new NumberFormatter(NumberFormat.getNumberInstance()),
                    new NumberFormatter(NumberFormat.getCurrencyInstance())));
    amountFld.setColumns(8);
    amountFld.setValue(simulationDataset.getInitial());
    amountFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setInitial(((Number) amountFld.getValue()).doubleValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, amountLbl, 0, SpringLayout.VERTICAL_CENTER,
            amountFld);
    springLayout.putConstraint(SpringLayout.WEST, amountFld, 0, SpringLayout.EAST, amountLbl);
    springLayout.putConstraint(SpringLayout.NORTH, amountFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(amountFld);

    // start date label
    JLabel fromLbl = new JLabel(Messages.getString("simulation.field.start-date")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, fromLbl, 10, SpringLayout.EAST, amountFld);
    simulationPanel.add(fromLbl);

    // start date field
    fromFld = new JFormattedTextField(new JodaLocalDateFormat());
    fromFld.setColumns(8);
    fromFld.setValue(simulationDataset.getStart());
    fromFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setStart((LocalDate) fromFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, fromLbl, 0, SpringLayout.VERTICAL_CENTER, fromFld);
    springLayout.putConstraint(SpringLayout.WEST, fromFld, 0, SpringLayout.EAST, fromLbl);
    springLayout.putConstraint(SpringLayout.NORTH, fromFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(fromFld);

    // end date label
    JLabel toLbl = new JLabel(Messages.getString("simulation.field.end-date")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, toLbl, 10, SpringLayout.EAST, fromFld);
    simulationPanel.add(toLbl);

    // end date field
    toFld = new JFormattedTextField(new JodaLocalDateFormat());
    toFld.setColumns(8);
    toFld.setValue(simulationDataset.getEnd());
    toFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setEnd((LocalDate) toFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, toLbl, 0, SpringLayout.VERTICAL_CENTER, toFld);
    springLayout.putConstraint(SpringLayout.WEST, toFld, 0, SpringLayout.EAST, toLbl);
    springLayout.putConstraint(SpringLayout.NORTH, toFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(toFld);

    // period label
    JLabel periodLbl = new JLabel(Messages.getString("simulation.field.period")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, periodLbl, 10, SpringLayout.EAST, toFld);
    simulationPanel.add(periodLbl);

    // period field
    periodFld = new JFormattedTextField(new JodaPeriodFormat());
    periodFld.setColumns(5);
    periodFld.setValue(simulationDataset.getPeriod());
    periodFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setPeriod((ReadablePeriod) periodFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, periodLbl, 0, SpringLayout.VERTICAL_CENTER,
            periodFld);
    springLayout.putConstraint(SpringLayout.WEST, periodFld, 0, SpringLayout.EAST, periodLbl);
    springLayout.putConstraint(SpringLayout.NORTH, periodFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(periodFld);

    // chart panel
    JFreeChart chart = ChartFactory.createLineChart("", Messages.getString("simulation.chart.date-axis-label"), //$NON-NLS-1$//$NON-NLS-2$
            Messages.getString("simulation.chart.amount-axis-label"), simulationDataset, //$NON-NLS-1$
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseToolTipGenerator(new SimulationTooltipGenerator(service));
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDismissDelay(3600000);
    chartPanel.setInitialDelay(0);
    springLayout.putConstraint(SpringLayout.NORTH, chartPanel, 15, SpringLayout.SOUTH, periodFld);
    springLayout.putConstraint(SpringLayout.WEST, chartPanel, 10, SpringLayout.WEST, simulationPanel);
    springLayout.putConstraint(SpringLayout.SOUTH, chartPanel, -10, SpringLayout.SOUTH, simulationPanel);
    springLayout.putConstraint(SpringLayout.EAST, chartPanel, -10, SpringLayout.EAST, simulationPanel);
    simulationPanel.add(chartPanel);
}

From source file:com.fratello.longevity.smooth.AppGUI.java

private void initialize() {
    LabelMaxSize = 0;// w  w w.  ja  v  a2s  .c  o m

    ActiveGUI = true;
    GUI_Start = false;
    GUI_Pause = true;
    GUI_Stop = false;
    ran_at_least_once = false;

    execute();

    initializeFields();

    frmFileSystemSearch = new JFrame();
    frmFileSystemSearch.setTitle("Smooth Longevity Fratello");
    frmFileSystemSearch.setBounds(100, 100, 450, 300);
    frmFileSystemSearch.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmFileSystemSearch.setResizable(false);

    UIManager.put("PopupMenu.border", BorderFactory.createLineBorder(Color.black, 1));

    JMenuBar menuBar = new JMenuBar();
    frmFileSystemSearch.setJMenuBar(menuBar);

    JMenu mnNewMenu = new JMenu("File");
    menuBar.add(mnNewMenu);

    JMenuItem mntmFirst = new JMenuItem("Open Directory");
    mntmFirst.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openFileChooserDir(mntmFirst);
        }
    });
    mnNewMenu.add(mntmFirst);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            frmFileSystemSearch.dispose();
        }
    });
    mnNewMenu.add(mntmExit);

    JMenu mnHelp = new JMenu("Help");
    menuBar.add(mnHelp);

    JMenuItem mntmAbout = new JMenuItem("About");
    mnHelp.add(mntmAbout);

    JMenuItem mntmTutorials = new JMenuItem("Tutorials");
    mnHelp.add(mntmTutorials);

    JMenuItem mntmCheckForUpdates = new JMenuItem("Check for Updates");
    mnHelp.add(mntmCheckForUpdates);

    String ppallink = "https://www.paypal.com/cgi-bin/webscr" + "?cmd=" + "_donations" + "&business="
            + "8YUJNSN6KFV54" + "&lc=" + "US" + "&item_name="
            + "Personal%20funds%20for%20programming%20at%20university" + "&currency_code=" + "USD" + "&bn="
            + "PP%2dDonationsBF" + "%3abtn_donateCC_LG%2egif%3aNonHosted";

    JButton btnDonate = new JButton("Donate");
    btnDonate.setToolTipText("<html>Open default Internet browser <br>(Chrome, FireFox, etc.)</html>");
    btnDonate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    btnDonate.setBounds(159, 176, 90, 25);
    menuBar.add(btnDonate);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    frmFileSystemSearch.getContentPane().add(tabbedPane, BorderLayout.CENTER);

    // ---------------------------- JPanels ------------------------------
    JPanel panel = new JPanel();
    tabbedPane.addTab("Start Directory", null, panel, null);

    JPanel panel_1 = new JPanel();
    tabbedPane.addTab("Search Setup", null, panel_1, null);
    panel_1.setLayout(null);

    JPanel panel_2 = new JPanel();
    tabbedPane.addTab("Run Program", null, panel_2, null);
    panel_2.setLayout(null);

    JPanel panel_3 = new JPanel();
    tabbedPane.addTab("Information", null, panel_3, null);
    panel_3.setBounds(10, 11, 409, 154);
    GridBagLayout gbl_panel_3 = new GridBagLayout();
    gbl_panel_3.columnWidths = new int[] { 0, 0, 0 };
    gbl_panel_3.rowHeights = new int[] { 0, 0, 0 };
    gbl_panel_3.columnWeights = new double[] { 1.0, 1.0, 1.0 };
    gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    panel_3.setLayout(gbl_panel_3);

    // ------------- Dynamic Update - Swingworker Components -------------
    SentinelProgressBar = new JProgressBar();
    SentinelProgressBar.setMaximumSize(new Dimension(146, 14));
    SentinelProgressBar.setMaximum(1000);
    SentinelProgressBar.setBounds(74, 187, 146, 14);
    panel_2.add(SentinelProgressBar);

    SentinelProgressLabel = new JLabel();
    SentinelProgressLabel.setToolTipText("Time needed to finish the program in progress");
    SentinelProgressLabel.setBounds(333, 181, 86, 20);
    panel_2.add(SentinelProgressLabel);

    // -------------------------------------------------------------------
    // ------------------------ JPanel Components ------------------------
    JLabel lblCurrentDirectory = new JLabel("Current Directory");
    panel.add(lblCurrentDirectory);

    userSelectedDirectories = new JTextField();
    panel.add(userSelectedDirectories);
    userSelectedDirectories.setColumns(35);

    JButton btnBrowse = new JButton("Browse");
    btnBrowse.setToolTipText("Locate directory in system");
    btnBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openFileChooserDir(btnBrowse);
        }
    });
    panel.add(btnBrowse);

    JButton btnClear = new JButton("Clear");
    btnClear.setToolTipText("Deletes the current directory shown");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            userSelectedDirectories.setText("");
            clearSourceDirectory();
        }
    });
    panel.add(btnClear);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_1 Components -----------------------

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Extension :: [Check Box]
    chckbxExt = new JCheckBox("Extension");
    chckbxExt.setToolTipText("Check to ignore file extensions");
    chckbxExt.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Ext", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Ext", false);
        }
    });
    chckbxExt.setBounds(8, 15, 97, 23);
    panel_1.add(chckbxExt);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Hash :: [Check Box]
    chckbxHash = new JCheckBox("Hash");
    chckbxHash.setToolTipText("Check to compare by hashing files (FAST)");
    chckbxHash.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Hash", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Hash", false);
        }
    });
    chckbxHash.setBounds(8, 45, 97, 23);
    panel_1.add(chckbxHash);

    // Hash :: [Combo Box]
    comboBoxHash = new JComboBox<String>();
    comboBoxHash.setToolTipText(
            "<html>Hash algorithm to use in file hashing <br>(note - SHA-512 may not be <br>supported by your computer)</html>");
    comboBoxHash.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setHashString(UIselect);
        }
    });
    comboBoxHash
            .setModel(new DefaultComboBoxModel<String>(new String[] { "MD5", "SHA-1", "SHA-256", "SHA-512" }));
    comboBoxHash.setBounds(150, 44, 75, 25);
    panel_1.add(comboBoxHash);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Name :: [Check Box]
    chckbxName = new JCheckBox("Name");
    chckbxName.setToolTipText("Name tool-tip goes here");
    chckbxName.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Name", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Name", false);
        }
    });
    chckbxName.setBounds(8, 75, 97, 23);
    panel_1.add(chckbxName);

    // Name :: [Text Field]
    namePercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    namePercentMatchTextField.setFormatterFactory(new DoubleDocListener(namePercentMatchTextField));
    namePercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(namePercentMatchTextField));
    namePercentMatchTextField.setToolTipText("Match file names by percentage [00.00-100.00]");
    namePercentMatchTextField.setBounds(150, 74, 110, 25);
    panel_1.add(namePercentMatchTextField);
    namePercentMatchTextField.setColumns(10);

    // Name :: [Combo Box]
    comboBoxNames = new JComboBox<String>();
    comboBoxNames.setToolTipText("Algorithm to compare names");
    comboBoxNames.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setMatchingAlgorithm(UIselect);
        }
    });
    comboBoxNames.setModel(new DefaultComboBoxModel<String>(new String[] { "Bitap", "Cosine",
            "DamerauLevenshtein", "DynamicTimeWarpingStandard1", "DynamicTimeWarpingStandard2", "Hamming",
            "Hirschberg", "JaccardIndex", "JaroWinkler", "Levenshtein", "NeedlemanWunsch", "SmithWaterman",
            "SorensenSimilarityIndex", "WagnerFischer" }));
    comboBoxNames.setBounds(265, 74, 150, 25);
    panel_1.add(comboBoxNames);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Size :: [Check Box]
    chckbxSize = new JCheckBox("Size");
    chckbxSize.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Size", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Size", false);
        }
    });
    chckbxSize.setBounds(8, 105, 97, 23);
    panel_1.add(chckbxSize);

    // Size :: [Text Field]
    sizePercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    sizePercentMatchTextField.setFormatterFactory(new DoubleDocListener(sizePercentMatchTextField));
    sizePercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(sizePercentMatchTextField));
    sizePercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]");
    sizePercentMatchTextField.setBounds(150, 104, 110, 25);
    panel_1.add(sizePercentMatchTextField);
    sizePercentMatchTextField.setColumns(10);

    // Size :: [Combo Box]
    comboBoxSize = new JComboBox<String>();
    comboBoxSize.setToolTipText("Specify byte grouping");
    comboBoxSize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setMetricSize(UIselect);
        }
    });
    comboBoxSize.setModel(
            new DefaultComboBoxModel<String>(new String[] { "BYTE", "KILOBYTE", "MEGABYTE", "GIGABYTE" }));
    comboBoxSize.setBounds(265, 104, 150, 25);
    panel_1.add(comboBoxSize);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Thorough :: [Check Box]
    chckbxThorough = new JCheckBox("Thorough");
    chckbxThorough.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Thorough", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Thorough", false);
        }
    });
    chckbxThorough.setToolTipText("Check byte by byte");
    chckbxThorough.setBounds(8, 135, 97, 23);
    panel_1.add(chckbxThorough);

    // Thorough :: [Text Field]
    thoroughPercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    thoroughPercentMatchTextField.setFormatterFactory(new DoubleDocListener(thoroughPercentMatchTextField));
    thoroughPercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(thoroughPercentMatchTextField));
    thoroughPercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]");
    thoroughPercentMatchTextField.setBounds(150, 134, 110, 25);
    panel_1.add(thoroughPercentMatchTextField);
    thoroughPercentMatchTextField.setColumns(10);

    // Thorough :: [Check Box]
    chckbxExitFast = new JCheckBox("Exit Fast");
    chckbxExitFast.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setThoroughExitFirstByteMisMatch(true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setThoroughExitFirstByteMisMatch(false);
        }
    });
    chckbxExitFast.setToolTipText("<html>When the first byte comparison <br>is a mis-match then stop</html>");
    chckbxExitFast.setBounds(265, 138, 105, 16);
    panel_1.add(chckbxExitFast);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    JButton btnSaveSearchSettings = new JButton("Save Search Settings");
    btnSaveSearchSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            pollSearchSettings();
            cf.saveObject();
            // System.out.println(cf.toString()); // debug
        }
    });
    btnSaveSearchSettings.setBounds(292, 181, 140, 25);
    panel_1.add(btnSaveSearchSettings);

    JButton btnLoadSettings = new JButton("Load Settings");
    btnLoadSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (!cf.loadObject())
                cf.setDefaultSettings();
            cacheUpdateGUISettings();
        }
    });
    btnLoadSettings.setBounds(148, 181, 140, 25);
    panel_1.add(btnLoadSettings);

    JButton btnDefaultSettings = new JButton("Use Default Settings");
    btnDefaultSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            cf.setDefaultSettings();
            cacheUpdateGUISettings();
        }
    });
    btnDefaultSettings.setBounds(4, 181, 140, 25);
    panel_1.add(btnDefaultSettings);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_2 Components -----------------------
    JLabel labelStatus = new JLabel("Progress");
    labelStatus.setBounds(10, 187, 54, 14);
    panel_2.add(labelStatus);

    JButton btnStart = new JButton("Start");
    btnStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pollSearchSettings();
            if (!ran_at_least_once)
                ran_at_least_once = true;
            else {
                SentinelProgressBar.setValue(0);
                SentinelProgressLabel.setText("Waiting...");
            }
            try {
                if (multiSelection == null) {
                    JOptionPane.showMessageDialog(btnStart, "Please enter at least one directory.",
                            "Press OK to continue", JOptionPane.PLAIN_MESSAGE);
                    return;
                }
                setSourceDirectory(multiSelection);
                GUI_Start = true;
            } catch (Exception err) {
                err.printStackTrace();
            }
        }
    });
    btnStart.setBounds(40, 153, 89, 23);
    panel_2.add(btnStart);

    JButton btnStop = new JButton("Stop");
    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GUI_Stop = true;
        }
    });
    btnStop.setBounds(169, 153, 89, 23);
    panel_2.add(btnStop);

    JButton btnNewButton = new JButton("Pause");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GUI_Pause = true;
        }
    });
    btnNewButton.setBounds(298, 153, 89, 23);
    panel_2.add(btnNewButton);

    JCheckBox chckbxDeleteDuplicateFiles = new JCheckBox("Delete duplicate files");
    chckbxDeleteDuplicateFiles.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            deleteCopyResults = true;
        }
    });
    chckbxDeleteDuplicateFiles.setBounds(230, 10, 150, 16);
    panel_2.add(chckbxDeleteDuplicateFiles);

    JCheckBox chckbxLogDuplicateFiles = new JCheckBox("Save duplicates to file");
    chckbxLogDuplicateFiles.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            saveCopyResults = true;
        }
    });
    chckbxLogDuplicateFiles.setBounds(230, 36, 150, 16);
    panel_2.add(chckbxLogDuplicateFiles);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_3 Components -----------------------

    JLabel lblAbout = new JLabel("About");
    GridBagConstraints gbc_lblAbout = new GridBagConstraints();
    gbc_lblAbout.insets = new Insets(0, 0, 5, 5);
    gbc_lblAbout.gridx = 0;
    gbc_lblAbout.gridy = 0;
    panel_3.add(lblAbout, gbc_lblAbout);

    JLabel lblTutorials = new JLabel("Tutorials");
    GridBagConstraints gbc_lblTutorials = new GridBagConstraints();
    gbc_lblTutorials.insets = new Insets(0, 0, 5, 5);
    gbc_lblTutorials.gridx = 1;
    gbc_lblTutorials.gridy = 0;
    panel_3.add(lblTutorials, gbc_lblTutorials);

    JLabel lblUpdates = new JLabel("Updates");
    GridBagConstraints gbc_lblUpdates = new GridBagConstraints();
    gbc_lblUpdates.insets = new Insets(0, 0, 5, 0);
    gbc_lblUpdates.gridx = 2;
    gbc_lblUpdates.gridy = 0;
    panel_3.add(lblUpdates, gbc_lblUpdates);

    JButton btnInformation = new JButton("Information");
    btnInformation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnInformation = new GridBagConstraints();
    gbc_btnInformation.insets = new Insets(0, 0, 0, 5);
    gbc_btnInformation.gridx = 0;
    gbc_btnInformation.gridy = 1;
    panel_3.add(btnInformation, gbc_btnInformation);

    JButton btnExamples = new JButton("Examples");
    btnExamples.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnExamples = new GridBagConstraints();
    gbc_btnExamples.insets = new Insets(0, 0, 0, 5);
    gbc_btnExamples.gridx = 1;
    gbc_btnExamples.gridy = 1;
    panel_3.add(btnExamples, gbc_btnExamples);

    JButton btnCheckNow = new JButton("Check Now");
    btnCheckNow.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnCheckNow = new GridBagConstraints();
    gbc_btnCheckNow.gridx = 2;
    gbc_btnCheckNow.gridy = 1;
    panel_3.add(btnCheckNow, gbc_btnCheckNow);
}

From source file:edu.harvard.mcz.imagecapture.GeoreferenceDialog.java

private void init() {
    setBounds(100, 100, 450, 560);/*from   w  ww . j  a  v  a 2  s .co m*/
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new GridLayout(0, 2, 0, 0));
    {
        JLabel lblLatitude = new JLabel("Latitude");
        lblLatitude.setHorizontalAlignment(SwingConstants.RIGHT);
        contentPanel.add(lblLatitude);
    }

    textFieldDecimalLat = new JTextField();
    contentPanel.add(textFieldDecimalLat);
    textFieldDecimalLat.setColumns(10);

    JLabel lblLongitude = new JLabel("Longitude");
    lblLongitude.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongitude);
    {
        textFieldDecimalLong = new JTextField();
        contentPanel.add(textFieldDecimalLong);
        textFieldDecimalLong.setColumns(10);
    }
    {
        JLabel lblDatum = new JLabel("Datum");
        lblDatum.setHorizontalAlignment(SwingConstants.RIGHT);
        contentPanel.add(lblDatum);
    }

    @SuppressWarnings("unchecked")
    ComboBoxModel<String> datumModel = new ListComboBoxModel<String>(LatLong.getDatumValues());
    cbDatum = new JComboBox<String>(datumModel);
    contentPanel.add(cbDatum);

    JLabel lblMethod = new JLabel("Method");
    lblMethod.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblMethod);

    @SuppressWarnings("unchecked")
    ComboBoxModel<String> methodModel = new ListComboBoxModel<String>(LatLong.getGeorefMethodValues());
    cbMethod = new JComboBox<String>(new DefaultComboBoxModel<String>(new String[] { "not recorded", "unknown",
            "GEOLocate", "Google Earth", "Gazeteer", "GPS", "MaNIS/HertNet/ORNIS Georeferencing Guidelines" }));
    cbMethod.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setState();
        }
    });
    contentPanel.add(cbMethod);

    JLabel lblAccuracy = new JLabel("GPS Accuracy");
    lblAccuracy.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblAccuracy);

    txtGPSAccuracy = new JTextField();
    txtGPSAccuracy.setColumns(10);
    contentPanel.add(txtGPSAccuracy);

    JLabel lblNewLabel_1 = new JLabel("Original Units");
    lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblNewLabel_1);

    comboBoxOrigUnits = new JComboBox<String>();
    comboBoxOrigUnits.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setState();
        }
    });
    comboBoxOrigUnits.setModel(new DefaultComboBoxModel<String>(
            new String[] { "decimal degrees", "deg. min. sec.", "degrees dec. minutes", "unknown" }));
    contentPanel.add(comboBoxOrigUnits);

    lblErrorRadius = new JLabel("Error Radius");
    lblErrorRadius.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblErrorRadius);

    txtErrorRadius = new JTextField();
    txtErrorRadius.setColumns(10);
    contentPanel.add(txtErrorRadius);

    JLabel lblErrorRadiusUnits = new JLabel("Error Radius Units");
    lblErrorRadiusUnits.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblErrorRadiusUnits);

    comboBoxErrorUnits = new JComboBox<String>();
    comboBoxErrorUnits.setModel(new DefaultComboBoxModel<String>(new String[] { "m", "ft", "km", "mi", "yd" }));
    contentPanel.add(comboBoxErrorUnits);

    JLabel lblLatDegrees = new JLabel("Lat Degrees");
    lblLatDegrees.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatDegrees);

    txtLatDegrees = new JTextField();
    txtLatDegrees.setColumns(4);
    contentPanel.add(txtLatDegrees);

    JLabel lblLatDecMin = new JLabel("Lat Dec Min");
    lblLatDecMin.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatDecMin);

    txtLatDecMin = new JTextField();
    txtLatDecMin.setColumns(6);
    contentPanel.add(txtLatDecMin);

    JLabel lblLatMin = new JLabel("Lat Min");
    lblLatMin.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatMin);

    txtLatMin = new JTextField();
    txtLatMin.setColumns(6);
    contentPanel.add(txtLatMin);

    JLabel lblLatSec = new JLabel("Lat Sec");
    lblLatSec.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatSec);

    txtLatSec = new JTextField();
    txtLatSec.setColumns(6);
    contentPanel.add(txtLatSec);

    JLabel lblLatDir = new JLabel("Lat N/S");
    lblLatDir.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatDir);

    cbLatDir = new JComboBox<String>();
    cbLatDir.setModel(new DefaultComboBoxModel<String>(new String[] { "N", "S" }));
    contentPanel.add(cbLatDir);

    JLabel lblLongDegrees = new JLabel("Long Degrees");
    lblLongDegrees.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongDegrees);

    txtLongDegrees = new JTextField();
    txtLongDegrees.setColumns(4);
    contentPanel.add(txtLongDegrees);

    JLabel lblLongDecMin = new JLabel("Long Dec Min");
    lblLongDecMin.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongDecMin);

    txtLongDecMin = new JTextField();
    txtLongDecMin.setColumns(6);
    contentPanel.add(txtLongDecMin);

    JLabel lblLongMin = new JLabel("Long Min");
    lblLongMin.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongMin);

    txtLongMin = new JTextField();
    txtLongMin.setColumns(6);
    contentPanel.add(txtLongMin);

    JLabel lblLongSec = new JLabel("Long Sec");
    lblLongSec.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongSec);

    txtLongSec = new JTextField();
    txtLongSec.setColumns(6);
    contentPanel.add(txtLongSec);

    JLabel lblLongDir = new JLabel("Long E/W");
    lblLongDir.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongDir);

    cbLongDir = new JComboBox<String>();
    cbLongDir.setModel(new DefaultComboBoxModel<String>(new String[] { "E", "W" }));
    contentPanel.add(cbLongDir);

    JLabel lblDetBy = new JLabel("Determined By");
    lblDetBy.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblDetBy);

    textFieldDetBy = new JTextField();
    contentPanel.add(textFieldDetBy);
    textFieldDetBy.setColumns(10);

    JLabel lblDetDate = new JLabel("Date Determined");
    lblDetDate.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblDetDate);

    try {
        textDetDate = new JFormattedTextField(new MaskFormatter("####-##-##"));
    } catch (ParseException e1) {
        textDetDate = new JFormattedTextField();
    }
    textDetDate.setToolTipText("Date on which georeference was made yyyy-mm-dd");
    contentPanel.add(textDetDate);

    JLabel lblRef = new JLabel("Reference Source");
    lblRef.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblRef);

    textRefSource = new JTextField();
    contentPanel.add(textRefSource);
    textRefSource.setColumns(10);

    lblNewLabel = new JLabel("Remarks");
    lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblNewLabel);

    textFieldRemarks = new JTextField();
    contentPanel.add(textFieldRemarks);
    textFieldRemarks.setColumns(10);

    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            lblErrorLabel = new JLabel("Message");
            buttonPane.add(lblErrorLabel);
        }
        {
            okButton = new JButton("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    lblErrorLabel.setText("");

                    if (saveData()) {
                        setVisible(false);
                    }
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    loadData();
                    setVisible(false);
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}

From source file:com.alvermont.terraj.planet.ui.MainFrame.java

/** This method is called from within the constructor to
 * initialize the form./*from w w w.  j ava 2s  .co  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */

// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    jButton1 = new javax.swing.JButton();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    projPanel = new javax.swing.JPanel();
    projComboBox = new javax.swing.JComboBox<Projector>();
    jLabel1 = new javax.swing.JLabel();
    latSpinner = new javax.swing.JSpinner();
    lonSpinner = new javax.swing.JSpinner();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    previewLabel = new javax.swing.JLabel();
    heightfieldCheckbox = new javax.swing.JCheckBox();
    jLabel17 = new javax.swing.JLabel();
    NumberFormat format = NumberFormat.getInstance();
    format.setMinimumFractionDigits(12);
    format.setMaximumFractionDigits(12);
    seedField = new JFormattedTextField(format);
    randomSeedButton = new javax.swing.JButton();
    randomAllButton = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    vgridSpinner = new javax.swing.JSpinner();
    hgridSpinner = new javax.swing.JSpinner();
    outputJPanel = new javax.swing.JPanel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    widthComboBox = new javax.swing.JComboBox<String>();
    heightComboBox = new javax.swing.JComboBox<String>();
    reverseCheckbox = new javax.swing.JCheckBox();
    jLabel18 = new javax.swing.JLabel();
    scaleSpinner = new javax.swing.JSpinner();
    jPanel3 = new javax.swing.JPanel();
    oceanColourButton = new javax.swing.JButton();
    shoreColourButton = new javax.swing.JButton();
    lowColourButton = new javax.swing.JButton();
    highColourButton = new javax.swing.JButton();
    mountainColourButton = new javax.swing.JButton();
    rockyColourButton = new javax.swing.JButton();
    peakColourButton = new javax.swing.JButton();
    spaceColourButton = new javax.swing.JButton();
    lineColourButton = new javax.swing.JButton();
    jLabel8 = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    jLabel11 = new javax.swing.JLabel();
    jLabel12 = new javax.swing.JLabel();
    jLabel13 = new javax.swing.JLabel();
    jLabel14 = new javax.swing.JLabel();
    jLabel15 = new javax.swing.JLabel();
    jLabel16 = new javax.swing.JLabel();
    randomAllColourButton = new javax.swing.JButton();
    randomOceanColourButton = new javax.swing.JButton();
    randomShoreColourButton = new javax.swing.JButton();
    randomLowColourButton = new javax.swing.JButton();
    randomHighColourButton = new javax.swing.JButton();
    randomMountainColourButton = new javax.swing.JButton();
    randomRockyColourButton = new javax.swing.JButton();
    randomPeakColourButton = new javax.swing.JButton();
    randomSpaceColourButton = new javax.swing.JButton();
    randomLineColourButton = new javax.swing.JButton();
    optionsPanel = new javax.swing.JPanel();
    altColourCheckbox = new javax.swing.JCheckBox();
    laticCheckbox = new javax.swing.JCheckBox();
    shadeCheckbox = new javax.swing.JCheckBox();
    shadeAngleSpinner = new javax.swing.JSpinner();
    lighterSpinner = new javax.swing.JSpinner();
    jLabel19 = new javax.swing.JLabel();
    outlineCheckbox = new javax.swing.JCheckBox();
    edgesCheckbox = new javax.swing.JCheckBox();
    jMenuBar1 = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    loadParamsItem = new javax.swing.JMenuItem();
    saveParamsItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    exitItem = new javax.swing.JMenuItem();
    optionsMenu = new javax.swing.JMenu();
    nativeLAFCheckbox = new javax.swing.JCheckBoxMenuItem();
    helpMenu = new javax.swing.JMenu();
    aboutItem = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Terrain Generator");
    jButton1.setAction(new GenerateAction(this, "Generate"));
    jButton1.setText("Generate ...");
    jButton1.setToolTipText("Generate the terrain using the parameters you have set up");
    jButton1.setPreferredSize(new java.awt.Dimension(120, 23));

    jTabbedPane1.setToolTipText("");
    projPanel.setRequestFocusEnabled(false);
    projComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            projComboBoxActionPerformed(evt);
        }
    });

    jLabel1.setText("Projection Type");
    jLabel1.setToolTipText("Specify the map projection to be used");

    latSpinner.setModel(new SpinnerNumberModel(0.0, -90.0, 90.0, 0.001));
    latSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            latSpinnerStateChanged(evt);
        }
    });

    lonSpinner.setModel(new SpinnerNumberModel(0.0, -180.0, 180.0, 0.001));
    lonSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            lonSpinnerStateChanged(evt);
        }
    });

    jLabel2.setText("Latitude");
    jLabel2.setToolTipText("Set the latitude for the projection");

    jLabel3.setText("Longitude");
    jLabel3.setToolTipText("Set the longitude for the projection");

    previewLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    previewLabel.setText("Not Initialized!");
    previewLabel.setToolTipText("A preview of the map projection");
    previewLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

    heightfieldCheckbox.setText("Don't use a projection, generate heightfield output");
    heightfieldCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    heightfieldCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    heightfieldCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            heightfieldCheckboxActionPerformed(evt);
        }
    });

    jLabel17.setText("Seed value for random terrain generation");
    jLabel17.setToolTipText("Set the seed value. A  particular seed will produce the same terrain");

    seedField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    seedField.setText("0.0");
    seedField.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            seedFieldActionPerformed(evt);
        }
    });

    randomSeedButton.setText("Random Seed");
    randomSeedButton.setToolTipText("Pick a random seed value");
    randomSeedButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomSeedButtonActionPerformed(evt);
        }
    });

    randomAllButton.setText("Randomize All");
    randomAllButton.setToolTipText("Randomize all the items on this page");
    randomAllButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomAllButtonActionPerformed(evt);
        }
    });

    org.jdesktop.layout.GroupLayout projPanelLayout = new org.jdesktop.layout.GroupLayout(projPanel);
    projPanel.setLayout(projPanelLayout);
    projPanelLayout.setHorizontalGroup(projPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, projPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, previewLabel,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 662, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, heightfieldCheckbox)
                            .add(projPanelLayout.createSequentialGroup()
                                    .add(projPanelLayout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(jLabel1).add(jLabel2).add(jLabel3).add(jLabel17))
                                    .add(145, 145, 145)
                                    .add(projPanelLayout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, lonSpinner,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, latSpinner,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, projComboBox, 0, 318,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, seedField,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, projPanelLayout
                                                    .createSequentialGroup().add(randomSeedButton)
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED,
                                                            116, Short.MAX_VALUE)
                                                    .add(randomAllButton)))))
                    .addContainerGap()));
    projPanelLayout.setVerticalGroup(projPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(projPanelLayout.createSequentialGroup().addContainerGap()
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel1).add(projComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(latSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel2))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lonSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel3))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel17).add(seedField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(randomAllButton).add(randomSeedButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(previewLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(heightfieldCheckbox)
                    .addContainerGap()));
    jTabbedPane1.addTab("Project", null, projPanel, "Set the projection parameters");

    jLabel4.setText("Add a grid at this vertical spacing in degrees (0 = none)");

    jLabel5.setText("Add a grid at this horizontal spacing in degrees (0 = none)");

    vgridSpinner.setModel(new SpinnerNumberModel(0.0, -90.0, 90.0, 0.001));
    vgridSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            vgridSpinnerStateChanged(evt);
        }
    });

    hgridSpinner.setModel(new SpinnerNumberModel(0.0, -180.0, 180.0, 0.001));
    hgridSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            hgridSpinnerStateChanged(evt);
        }
    });

    org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup().addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel4)
                            .add(jLabel5))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 290, Short.MAX_VALUE)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(hgridSpinner).add(vgridSpinner, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    93, Short.MAX_VALUE))
                    .addContainerGap()));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup().addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel4).add(vgridSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel5).add(hgridSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(334, Short.MAX_VALUE)));
    jTabbedPane1.addTab("Grid", null, jPanel1, "Set the grid parameters");

    jLabel6.setText("Output width in pixels");

    jLabel7.setText("Output height in pixels");

    widthComboBox.setEditable(true);
    widthComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(
            new String[] { "320", "640", "800", "1024", "1280", "1600" }));
    widthComboBox.setSelectedIndex(2);
    widthComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            widthComboBoxActionPerformed(evt);
        }
    });

    heightComboBox.setEditable(true);
    heightComboBox.setModel(
            new javax.swing.DefaultComboBoxModel<>(new String[] { "200", "480", "600", "1024", "1200" }));
    heightComboBox.setSelectedIndex(2);
    heightComboBox.addActionListener(evt -> heightComboBoxActionPerformed(evt)); /*new java.awt.event.ActionListener()
                                                                                 {
                                                                                 public void actionPerformed(java.awt.event.ActionEvent evt)
                                                                                 {
                                                                                 heightComboBoxActionPerformed(evt);
                                                                                 }
                                                                                 });*/

    reverseCheckbox.setText("Reverse the background on the output");
    reverseCheckbox.setToolTipText("If selected will invert the background colour");
    reverseCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    reverseCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));

    jLabel18.setText("Scale (1.0 = normal)");

    scaleSpinner.setModel(new SpinnerNumberModel(1.0, 0.01, 10.0, 0.01));
    scaleSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            scaleSpinnerStateChanged(evt);
        }
    });

    org.jdesktop.layout.GroupLayout outputJPanelLayout = new org.jdesktop.layout.GroupLayout(outputJPanel);
    outputJPanel.setLayout(outputJPanelLayout);
    outputJPanelLayout.setHorizontalGroup(outputJPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(outputJPanelLayout.createSequentialGroup().addContainerGap().add(outputJPanelLayout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(outputJPanelLayout.createSequentialGroup()
                            .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel6).add(jLabel7))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 458, Short.MAX_VALUE)
                            .add(outputJPanelLayout
                                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(heightComboBox, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                            Short.MAX_VALUE)
                                    .add(widthComboBox, 0, 85, Short.MAX_VALUE)))
                    .add(outputJPanelLayout.createSequentialGroup().add(jLabel18)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 401, Short.MAX_VALUE)
                            .add(scaleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(reverseCheckbox)).addContainerGap()));
    outputJPanelLayout.setVerticalGroup(outputJPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(outputJPanelLayout.createSequentialGroup().addContainerGap()
                    .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel6).add(widthComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel7).add(heightComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel18).add(scaleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(reverseCheckbox)
                    .addContainerGap(283, Short.MAX_VALUE)));
    jTabbedPane1.addTab("Output", null, outputJPanel, "Set the output parameters");

    oceanColourButton.setText("Select ...");
    oceanColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            oceanColourButtonActionPerformed(evt);
        }
    });

    shoreColourButton.setText("Select ...");
    shoreColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            shoreColourButtonActionPerformed(evt);
        }
    });

    lowColourButton.setText("Select ...");
    lowColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            lowColourButtonActionPerformed(evt);
        }
    });

    highColourButton.setText("Select ...");
    highColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            highColourButtonActionPerformed(evt);
        }
    });

    mountainColourButton.setText("Select ...");
    mountainColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            mountainColourButtonActionPerformed(evt);
        }
    });

    rockyColourButton.setText("Select ...");
    rockyColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            rockyColourButtonActionPerformed(evt);
        }
    });

    peakColourButton.setText("Select ...");
    peakColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            peakColourButtonActionPerformed(evt);
        }
    });

    spaceColourButton.setText("Select ...");
    spaceColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            spaceColourButtonActionPerformed(evt);
        }
    });

    lineColourButton.setText("Select ...");
    lineColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            lineColourButtonActionPerformed(evt);
        }
    });

    jLabel8.setText("Colour to use for ocean depths");

    jLabel9.setText("Colour to use for shores");

    jLabel10.setText("Colour to use for lowlands");

    jLabel11.setText("Colour to use for highlands");

    jLabel12.setText("Colour to use for mountains");

    jLabel13.setText("Colour to use for high rocky peaks");

    jLabel14.setText("Colour to use for peaks");

    jLabel15.setText("Colour to use for space");

    jLabel16.setText("Colour to use for lines");

    randomAllColourButton.setText("Randomize All Colours");
    randomAllColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomAllColourButtonActionPerformed(evt);
        }
    });

    randomOceanColourButton.setText("Random");
    randomOceanColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomOceanColourButtonActionPerformed(evt);
        }
    });

    randomShoreColourButton.setText("Random");
    randomShoreColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomShoreColourButtonActionPerformed(evt);
        }
    });

    randomLowColourButton.setText("Random");
    randomLowColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomLowColourButtonActionPerformed(evt);
        }
    });

    randomHighColourButton.setText("Random");
    randomHighColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomHighColourButtonActionPerformed(evt);
        }
    });

    randomMountainColourButton.setText("Random");
    randomMountainColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomMountainColourButtonActionPerformed(evt);
        }
    });

    randomRockyColourButton.setText("Random");
    randomRockyColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomRockyColourButtonActionPerformed(evt);
        }
    });

    randomPeakColourButton.setText("Random");
    randomPeakColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomPeakColourButtonActionPerformed(evt);
        }
    });

    randomSpaceColourButton.setText("Random");
    randomSpaceColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomSpaceColourButtonActionPerformed(evt);
        }
    });

    randomLineColourButton.setText("Random");
    randomLineColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomLineColourButtonActionPerformed(evt);
        }
    });

    org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout
            .setHorizontalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup().addContainerGap().add(jPanel3Layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                                    jPanel3Layout
                                            .createSequentialGroup().add(
                                                    jPanel3Layout
                                                            .createParallelGroup(
                                                                    org.jdesktop.layout.GroupLayout.LEADING)
                                                            .add(jLabel8).add(jLabel9).add(jLabel10)
                                                            .add(jLabel11).add(jLabel12).add(jLabel13)
                                                            .add(jLabel14).add(jLabel15).add(jLabel16))
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 222,
                                                    Short.MAX_VALUE)
                                            .add(jPanel3Layout
                                                    .createParallelGroup(
                                                            org.jdesktop.layout.GroupLayout.TRAILING)
                                                    .add(randomOceanColourButton).add(randomShoreColourButton)
                                                    .add(randomLowColourButton).add(randomMountainColourButton)
                                                    .add(randomRockyColourButton).add(
                                                            randomPeakColourButton)
                                                    .add(randomSpaceColourButton).add(randomLineColourButton)
                                                    .add(randomHighColourButton))
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(jPanel3Layout
                                                    .createParallelGroup(
                                                            org.jdesktop.layout.GroupLayout.LEADING, false)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            oceanColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            shoreColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            lowColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            highColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            mountainColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            rockyColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            peakColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            spaceColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            lineColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, randomAllColourButton))
                            .addContainerGap()));
    jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup().addContainerGap()
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(oceanColourButton).add(jLabel8).add(randomOceanColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(shoreColourButton).add(jLabel9).add(randomShoreColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lowColourButton).add(jLabel10).add(randomLowColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(highColourButton).add(jLabel11).add(randomHighColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(mountainColourButton).add(jLabel12).add(randomMountainColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(rockyColourButton).add(jLabel13).add(randomRockyColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(peakColourButton).add(jLabel14).add(randomPeakColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(spaceColourButton).add(jLabel15).add(randomSpaceColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lineColourButton).add(jLabel16).add(randomLineColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 91, Short.MAX_VALUE)
                    .add(randomAllColourButton).addContainerGap()));
    jTabbedPane1.addTab("Colours", null, jPanel3, "Set the colour parameters");

    altColourCheckbox.setText("Use an alternative colouring scheme");
    altColourCheckbox.setToolTipText("An alternate colour scheme more like an atlas");
    altColourCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    altColourCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    altColourCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            altColourCheckboxActionPerformed(evt);
        }
    });

    laticCheckbox.setText("Use latitude based colouring");
    laticCheckbox.setToolTipText("Colour terrain based on latitude");
    laticCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    laticCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    laticCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            laticCheckboxActionPerformed(evt);
        }
    });

    shadeCheckbox.setText("Do shading with light angle (degrees)");
    shadeCheckbox.setToolTipText("Use bumpmap shading on the terrain");
    shadeCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    shadeCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    shadeCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            shadeCheckboxActionPerformed(evt);
        }
    });

    shadeAngleSpinner.setModel(new SpinnerNumberModel(150.0, 0.0, 360.0, 0.1));
    shadeAngleSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            shadeAngleSpinnerStateChanged(evt);
        }
    });

    lighterSpinner.setModel(new SpinnerNumberModel(0, 0, 100, 1));
    lighterSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            lighterSpinnerStateChanged(evt);
        }
    });

    jLabel19.setText("Lighten colours by this amount (doesn't work with alt colours)");
    jLabel19.setToolTipText("Use lighter colouring");

    outlineCheckbox.setText("Draw in outline mode only");
    outlineCheckbox.setToolTipText("Draw a black and white coastline output only");
    outlineCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    outlineCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    outlineCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            outlineCheckboxActionPerformed(evt);
        }
    });

    edgesCheckbox.setText("Draw the edges of coastlines in black");
    edgesCheckbox.setToolTipText("Outline the coasts in black");
    edgesCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    edgesCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    edgesCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            edgesCheckboxActionPerformed(evt);
        }
    });

    org.jdesktop.layout.GroupLayout optionsPanelLayout = new org.jdesktop.layout.GroupLayout(optionsPanel);
    optionsPanel.setLayout(optionsPanelLayout);
    optionsPanelLayout.setHorizontalGroup(optionsPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(optionsPanelLayout.createSequentialGroup().addContainerGap().add(optionsPanelLayout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(altColourCheckbox)
                    .add(laticCheckbox)
                    .add(optionsPanelLayout.createSequentialGroup().add(shadeCheckbox)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 304, Short.MAX_VALUE)
                            .add(shadeAngleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                            optionsPanelLayout.createSequentialGroup().add(17, 17, 17).add(jLabel19)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 189,
                                            Short.MAX_VALUE)
                                    .add(lighterSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163,
                                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(optionsPanelLayout.createSequentialGroup().add(17, 17, 17).add(outlineCheckbox))
                    .add(edgesCheckbox)).addContainerGap()));
    optionsPanelLayout.setVerticalGroup(optionsPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(optionsPanelLayout.createSequentialGroup().addContainerGap().add(altColourCheckbox)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(laticCheckbox)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(optionsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(shadeCheckbox).add(shadeAngleSpinner,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(optionsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lighterSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel19))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(edgesCheckbox)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(outlineCheckbox)
                    .addContainerGap(250, Short.MAX_VALUE)));

    optionsPanelLayout.linkSize(new java.awt.Component[] { altColourCheckbox, laticCheckbox, shadeCheckbox },
            org.jdesktop.layout.GroupLayout.VERTICAL);

    jTabbedPane1.addTab("Options", null, optionsPanel, "Set the rest of the options");

    fileMenu.setText("File");
    loadParamsItem.setText("Load Settings ...");
    loadParamsItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loadParamsItemActionPerformed(evt);
        }
    });

    fileMenu.add(loadParamsItem);

    saveParamsItem.setText("Save Settings ...");
    saveParamsItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveParamsItemActionPerformed(evt);
        }
    });

    fileMenu.add(saveParamsItem);

    fileMenu.add(jSeparator1);

    exitItem.setText("Exit ...");
    exitItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitItemActionPerformed(evt);
        }
    });

    fileMenu.add(exitItem);

    jMenuBar1.add(fileMenu);

    optionsMenu.setText("Options");
    nativeLAFCheckbox.setText("Use system look and feel");
    nativeLAFCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            nativeLAFCheckboxActionPerformed(evt);
        }
    });

    optionsMenu.add(nativeLAFCheckbox);

    jMenuBar1.add(optionsMenu);

    helpMenu.setText("Help");
    aboutItem.setText("About ...");
    aboutItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            aboutItemActionPerformed(evt);
        }
    });

    helpMenu.add(aboutItem);

    jMenuBar1.add(helpMenu);

    setJMenuBar(jMenuBar1);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton1,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 687,
                                    Short.MAX_VALUE))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup().addContainerGap()
                    .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 416, Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 715) / 2, (screenSize.height - 515) / 2, 715, 515);
}

From source file:Converter.java

ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) {
    if (MULTICOLORED) {
        setOpaque(true);/*from  ww w  . j  a va  2s .c o m*/
        setBackground(new Color(0, 255, 255));
    }
    setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Save arguments in instance variables.
    controller = myController;
    units = myUnits;
    title = myTitle;
    sliderModel = myModel;

    // Create the text field format, and then the text field.
    numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMaximumFractionDigits(2);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setAllowsInvalid(false);
    formatter.setCommitsOnValidEdit(true);// seems to be a no-op --
    // aha -- it changes the value property but doesn't cause the result to
    // be parsed (that happens on focus loss/return, I think).
    //
    textField = new JFormattedTextField(formatter);
    textField.setColumns(10);
    textField.setValue(new Double(sliderModel.getDoubleValue()));
    textField.addPropertyChangeListener(this);

    // Add the combo box.
    unitChooser = new JComboBox();
    for (int i = 0; i < units.length; i++) { // Populate it.
        unitChooser.addItem(units[i].description);
    }
    unitChooser.setSelectedIndex(0);
    sliderModel.setMultiplier(units[0].multiplier);
    unitChooser.addActionListener(this);

    // Add the slider.
    slider = new JSlider(sliderModel);
    sliderModel.addChangeListener(this);

    // Make the text field/slider group a fixed size
    // to make stacked ConversionPanels nicely aligned.
    JPanel unitGroup = new JPanel() {
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }

        public Dimension getPreferredSize() {
            return new Dimension(150, super.getPreferredSize().height);
        }

        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
        unitGroup.setOpaque(true);
        unitGroup.setBackground(new Color(0, 0, 255));
    }
    unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    unitGroup.add(textField);
    unitGroup.add(slider);

    // Create a subpanel so the combo box isn't too tall
    // and is sufficiently wide.
    JPanel chooserPanel = new JPanel();
    chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
        chooserPanel.setOpaque(true);
        chooserPanel.setBackground(new Color(255, 0, 255));
    }
    chooserPanel.add(unitChooser);
    chooserPanel.add(Box.createHorizontalStrut(100));

    // Put everything together.
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(unitGroup);
    add(chooserPanel);
    unitGroup.setAlignmentY(TOP_ALIGNMENT);
    chooserPanel.setAlignmentY(TOP_ALIGNMENT);
}

From source file:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java

/**
 * This method initializes jNombreTarjetaTextField   
 *    /*w ww . ja va 2s. co  m*/
 * @return javax.swing.JTextField   
 */
private JFormattedTextField getJNombreTarjetaTextField() {
    if (jNombreTarjetaTextField == null) {

        // El nombre de la tarjeta solo acepta letras y nmeros
        // Se agrega la barra baja como separador
        MaskFormatter formato = new MaskFormatter();
        formato.setValidCharacters(CARACTERES_VALIDOS);
        formato.setAllowsInvalid(false);
        try {
            formato.setMask(MASK);
        } catch (ParseException e) {
            // Nunca ocurre
        }

        jNombreTarjetaTextField = new JFormattedTextField(formato);
        jNombreTarjetaTextField.setFocusLostBehavior(javax.swing.JFormattedTextField.COMMIT);
    }
    return jNombreTarjetaTextField;
}

From source file:com.github.dougkelly88.FLIMPlateReaderGUI.SequencingClasses.GUIComponents.XYSequencing.java

private void genZStackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genZStackButtonActionPerformed
    //TODO: generate new FOV in current position if FOV table is empty. 
    //TODO: /*from  w  ww . j  a va 2s.  co  m*/

    double startUm = -1.0;
    double endUm = -1.0;
    double stepUm = 1.0;

    String um = "(" + "\u00B5" + "m)";
    JLabel messageLabel = new JLabel("<html>Please enter start, end and delta values for Z stack: </html>");
    JLabel startLabel = new JLabel("Start Z position " + um + ":");
    JLabel endLabel = new JLabel("End Z position " + um + ":");
    JLabel stepLabel = new JLabel("Step size " + um + ":");

    // Uses a custom NumberFormat.
    NumberFormat customFormat = NumberFormat.getInstance(new Locale("en_US"));
    JFormattedTextField customFormatField = new JFormattedTextField(new NumberFormatter(customFormat));

    JFormattedTextField startField = new JFormattedTextField(customFormat);
    startField.setValue(-3.0);
    JFormattedTextField endField = new JFormattedTextField(customFormat);
    endField.setValue(3.0);
    JFormattedTextField stepField = new JFormattedTextField(customFormat);
    stepField.setValue(1.0);

    JPanel zStackDialog = new JPanel();
    zStackDialog.setLayout(new BorderLayout(50, 100));

    JPanel controlsPanel = new JPanel();
    controlsPanel.setLayout(new GridLayout(3, 2, 50, 10));

    controlsPanel.add(startLabel);
    controlsPanel.add(startField);
    controlsPanel.add(endLabel);
    controlsPanel.add(endField);
    controlsPanel.add(stepLabel);
    controlsPanel.add(stepField);

    zStackDialog.add(messageLabel, BorderLayout.PAGE_START);
    zStackDialog.add(controlsPanel, BorderLayout.CENTER);

    int result = JOptionPane.showConfirmDialog(this, zStackDialog, "Z stack setup",
            JOptionPane.OK_CANCEL_OPTION);
    if (result == JOptionPane.OK_OPTION) {

        // must be a better way to achieve this...?
        if (startField.getValue().getClass() == Double.class) {
            startUm = (Double) (startField.getValue());
        } else {
            startUm = ((Long) startField.getValue()).doubleValue();
        }

        if (endField.getValue().getClass() == Double.class) {
            endUm = (Double) (endField.getValue());
        } else {
            endUm = ((Long) endField.getValue()).doubleValue();
        }

        if (stepField.getValue().getClass() == Double.class) {
            stepUm = (Double) (stepField.getValue());
        } else {
            stepUm = ((Long) stepField.getValue()).doubleValue();
        }

        setZStackParams(startUm, endUm, stepUm);

        doZStackGeneration(getZStackParams());
    }

}

From source file:fll.scheduler.SchedulerUI.java

/**
 * Prompt the user for which columns represent subjective categories.
 * //from   w ww  .j  a  va2 s  .c  om
 * @param parentComponent the parent for the dialog
 * @param columnInfo the column information
 * @return the list of subjective information the user choose
 */
public static List<SubjectiveStation> gatherSubjectiveStationInformation(final Component parentComponent,
        final ColumnInformation columnInfo) {
    final List<String> unusedColumns = columnInfo.getUnusedColumns();
    final List<JCheckBox> checkboxes = new LinkedList<JCheckBox>();
    final List<JFormattedTextField> subjectiveDurations = new LinkedList<JFormattedTextField>();
    final Box optionPanel = Box.createVerticalBox();

    optionPanel.add(new JLabel("Specify which columns in the data file are for subjective judging"));

    final JPanel grid = new JPanel(new GridLayout(0, 2));
    optionPanel.add(grid);
    grid.add(new JLabel("Data file column"));
    grid.add(new JLabel("Duration (minutes)"));

    for (final String column : unusedColumns) {
        if (null != column && column.length() > 0) {
            final JCheckBox checkbox = new JCheckBox(column);
            checkboxes.add(checkbox);
            final JFormattedTextField duration = new JFormattedTextField(
                    Integer.valueOf(SchedParams.DEFAULT_SUBJECTIVE_MINUTES));
            duration.setColumns(4);
            subjectiveDurations.add(duration);
            grid.add(checkbox);
            grid.add(duration);
        }
    }
    final List<SubjectiveStation> subjectiveHeaders;
    if (!checkboxes.isEmpty()) {
        JOptionPane.showMessageDialog(parentComponent, optionPanel, "Choose Subjective Columns",
                JOptionPane.QUESTION_MESSAGE);
        subjectiveHeaders = new LinkedList<SubjectiveStation>();
        for (int i = 0; i < checkboxes.size(); ++i) {
            final JCheckBox box = checkboxes.get(i);
            final JFormattedTextField duration = subjectiveDurations.get(i);
            if (box.isSelected()) {
                subjectiveHeaders
                        .add(new SubjectiveStation(box.getText(), ((Number) duration.getValue()).intValue()));
            }
        }
    } else {
        subjectiveHeaders = Collections.emptyList();
    }

    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Subjective headers selected: " + subjectiveHeaders);
    }
    return subjectiveHeaders;
}