public BizSimMain(int numThreads, int numAgents, int numGenerations) { // configure our main window which will contain all the other elements JFrame control_window = new JFrame(); control_window.setTitle("Control Suite"); control_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); control_window.setSize(new Dimension(800, 480)); // control_window.setAlwaysOnTop(true); control_window.setLayout(new BorderLayout()); JPanel species_control = new JPanel(); JLabel species_list_l = new JLabel("Species Running"); DefaultListModel species_list = new DefaultListModel(); // create our Environment Environment e = new Environment(); // create all our threads for (int kittehsex = 0; kittehsex < numThreads; ++kittehsex) { // create some test agents ArrayList<Agent> agents = new ArrayList<Agent>(); for (int i = 0; i < numAgents; ++i) { agents.add(new Agent()); } // create our new thread and pass in some control variables ProcessSimulator ps = new ProcessSimulator(agents, numGenerations, kittehsex, e, this); Thread t = new Thread(ps); species.add(ps); // update our current species list species_list.addElement("Species #" + kittehsex); // set the thread to a high priority, and then start it t.setPriority(9); t.start(); } // create a selectable list of all the different species we have JList species_select_list = new JList(species_list); species_select_list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); species_select_list.setLayoutOrientation(JList.VERTICAL); species_select_list.setVisibleRowCount(3); // start listening to all buttons start_stop.addActionListener(this); reset.addActionListener(this); reconfigure.addActionListener(this); // add mnemonics to some buttons start_stop.setMnemonic('s'); reset.setMnemonic('r'); reconfigure.setMnemonic('e'); // create a panel for all our environment variables JPanel environment_controls = new JPanel(); environment_controls.setBorder(BorderFactory.createTitledBorder("Modify Finished Good Values")); environment_controls.setLayout(new GridLayout(3, 4)); environment_controls.add(new JLabel("High Rate:")); environment_controls.add(high_rate); environment_controls.add(new JLabel("High Sale:")); environment_controls.add(high_sale); environment_controls.add(new JLabel("Med Rate:")); environment_controls.add(med_rate); environment_controls.add(new JLabel("Med Sale:")); environment_controls.add(med_sale); environment_controls.add(new JLabel("Low Rate:")); environment_controls.add(low_rate); environment_controls.add(new JLabel("Low Sale:")); environment_controls.add(low_sale); // create a panel for all our simulation variables JPanel simulation_controls = new JPanel(); simulation_controls.setBorder(BorderFactory.createTitledBorder("Modify Simulation Controls")); simulation_controls.setLayout(new GridLayout(6, 2)); simulation_controls.add(new JLabel("Agent Count:")); simulation_controls.add(agent_count); simulation_controls.add(new JLabel("Generation Count:")); simulation_controls.add(generation_count); simulation_controls.add(new JLabel("Elite Percent")); simulation_controls.add(elite_percent); simulation_controls.add(new JLabel("Parent Percent")); simulation_controls.add(parent_percent); simulation_controls.add(new JLabel("Agent Performance")); simulation_controls.add(agent_performance); // create a panel for displaying information about the current elite // agent JPanel elite_panel = new JPanel(); elite_panel.setBorder(BorderFactory.createTitledBorder("Current Elite Agent Performance")); elite_panel.setLayout(new GridLayout(2, 2)); elite_panel.add(new JLabel("Total: ")); elite_panel.add(cur_elite_total); elite_panel.add(new JLabel("Genome: ")); JScrollPane genome_scroll = new JScrollPane(cur_elite_genome); elite_panel.add(genome_scroll); // this panel encompasses the different panels for altering and showing // the current state of the simulation JPanel field_controls = new JPanel(); field_controls.setLayout(new GridLayout(2, 2)); field_controls.add(environment_controls); field_controls.add(simulation_controls); field_controls.add(elite_panel); // set some attributes on misc. GUI stuff cur_elite_genome.setWrapStyleWord(true); cur_elite_genome.setEditable(false); cur_elite_genome.setLineWrap(true); // set the size of the button to just 3 characters high_rate.setColumns(3); high_sale.setColumns(3); med_rate.setColumns(3); med_sale.setColumns(3); low_rate.setColumns(3); low_sale.setColumns(3); // set the current value of our fields to the current environment value high_rate.setText(e.getHQRate() + ""); high_sale.setText(e.getHQSale() + ""); med_rate.setText(e.getMQRate() + ""); med_sale.setText(e.getMQSale() + ""); low_rate.setText(e.getLQRate() + ""); low_sale.setText(e.getLQSale() + ""); // set the default value of our fields to the current simulation values day_count.setText("100"); generation_count.setText(numGenerations + ""); elite_percent.setText(".05"); parent_percent.setText(".8"); agent_count.setText(numAgents + ""); agent_performance.setText(e.getIncomeRatioThreshold() + ""); // create a panel for all our flow control buttons JPanel control_flow_buttons = new JPanel(); control_flow_buttons.setLayout(new GridLayout(1, 6)); control_flow_buttons.add(start_stop); control_flow_buttons.add(reset); control_flow_buttons.add(reconfigure); // add our components to the window species_control.add(species_list_l); species_control.add(species_select_list); control_window.add(species_control, BorderLayout.WEST); control_window.add(field_controls, BorderLayout.CENTER); control_window.add(control_flow_buttons, BorderLayout.SOUTH); control_window.setLocation(620, 0); control_window.setVisible(true); }