• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting a Combobox to Radio Buttons  RSS feed

 
Collin Grey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I need to use radio buttons intead of a combo box. it works with the combo box but I am having problems changing it to Radio buttons.

For example

import java.applet.Applet;
import java.awt.*;
import java.io.*;

....
team_men = new Choice();
team_men.addItem("Not Cannon");
team_men.addItem("Cannon");
team_men.setBackground(color1);
add(team_men);
team_men.reshape(5, 160, 185, 20);
team_blue = new Choice();
team_blue.setBackground(color1);
team_blue.addItem("Not Pana");
team_blue.addItem("Pana");
team_blue.addItem("Split Pana");
team_blue.addItem("Blue Pana");
team_blue.addItem("Split Blue Pana");
add(team_blue);
team_blue.reshape(5, 40, 185, 20);
team_red = new Choice();
team_red.setBackground(color1);
team_red.addItem("No Gold");
team_red.addItem("Split Gold");
team_red.addItem("Gold");
team_red.addItem("Split American Gold");
team_red.addItem("American Gold");
team_red.addItem("Split Australian Silver");
team_red.addItem("Australian Silver");
team_red.addItem("Golden Silver");
add(team_red);
team_red.reshape(5, 80, 185, 20);
team_ladies = new Choice();
team_ladies.addItem("Not Cannon");
team_ladies.addItem("Cannon");
team_ladies.setBackground(color1);
add(team_ladies);
team_pink.reshape(255, 160, 185, 20);
team_pink = new Choice();
team_pink.setBackground(color1);
team_pink.addItem("No Gold");
team_pink.addItem("Gold");
team_pink.addItem("American Gold");
team_pink.addItem("Australian Silver");
add(team_pink);
team_pink.reshape(255, 80, 185, 20);
team_green = new Choice();
team_green.setBackground(color1);
team_green.addItem("Not Pana");
team_green.addItem("Pana");
team_green.addItem("Split Pana");
team_green.addItem("Blue Pana");
add(team_green);
team_green.reshape(255, 40, 185, 20);
.....etc

I need to have all the different team items (eg team_men) put into radio button groups with only the first choice selected.

Any help would be appreciated.

Collin
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RadioButtons were introduced in Swing. In the AWT we have Checkbox and CheckboxGroup to use. The CheckboxGroup makes the checkboxes mutually exclusive.

The general idea is to add each set of Checkboxes to a panel and then place the panel where you want.

An option to adding listeners is to loop through each set of checkboxes to get their state when it comes time to get the user's selections.
 
Collin Grey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thanks for the response, but I cannot get it to work.

Here is my appelet I would like to convert the comboboxes to radiobuttons with the first item of each radiogroup selected.

Any help would be appreciated.

Collin

import java.applet.Applet;
import java.awt.*;
import java.io.*;

public class teams extends Applet
{

public void init()
{
super.init();
setLayout(null);
resize(600, 500);
switch_key = true;
Font bigfont = new Font("TimesRoman", 1, 20);
Color backcolor = new Color(180, 210, 255);
Color groupcolor = new Color(255, 255, 255);
Color groupcolor2 = new Color(30, 255, 30);
Color color_white = new Color(255, 255, 255);
Color color_blue = new Color(0, 0, 255);
Color color_red = new Color(255, 0, 0);
Color color_green = new Color(0, 255, 0);
setBackground(backcolor);
label2 = new Label("A Team");
label2.setFont(bigfont);
add(label2);
label2.reshape(5, 0, 200, 24);
label3 = new Label("B Team");
label3.setFont(bigfont);
add(label3);
label3.reshape(255, 0, 550, 24);
pied_dad = new Choice();
pied_dad.addItem("Not Pied");
pied_dad.addItem("Pied");
pied_dad.setBackground(groupcolor);
add(pied_dad);
pied_dad.reshape(5, 160, 185, 20);
blue_dad = new Choice();
blue_dad.setBackground(groupcolor);
blue_dad.addItem("Not Blue");
blue_dad.addItem("Light Blue");
blue_dad.addItem("Split Light Blue");
blue_dad.addItem("Cobalt Blue");
blue_dad.addItem("Split Cobalt Blue");
blue_dad.addItem("Aquamarine");
add(blue_dad);
blue_dad.reshape(5, 40, 185, 20);
sexlink_dad = new Choice();
sexlink_dad.setBackground(groupcolor);
sexlink_dad.addItem("No Yellow");
sexlink_dad.addItem("Split Yellow");
sexlink_dad.addItem("Yellow");
sexlink_dad.addItem("Split Gold");
sexlink_dad.addItem("Gold");
sexlink_dad.addItem("Split Silver");
sexlink_dad.addItem("Silver");
sexlink_dad.addItem("Golden Silver");
sexlink_dad.addItem("Split Yellow + Split AmCinn");
sexlink_dad.addItem("Split AusCinn + Split AmCinn");
add(sexlink_dad);
sexlink_dad.reshape(5, 80, 185, 20);
pied_mom = new Choice();
pied_mom.addItem("Not Pied");
pied_mom.addItem("Pied");
pied_mom.setBackground(groupcolor);
add(pied_mom);
pied_mom.reshape(255, 160, 185, 20);
sexlink_mom = new Choice();
sexlink_mom.setBackground(groupcolor);
sexlink_mom.addItem("No Yellow");
sexlink_mom.addItem("Yellow");
sexlink_mom.addItem("Gold");
sexlink_mom.addItem("Silver");
add(sexlink_mom);
sexlink_mom.reshape(255, 80, 185, 20);
blue_mom = new Choice();
blue_mom.setBackground(groupcolor);
blue_mom.addItem("Not Blue");
blue_mom.addItem("Light Blue");
blue_mom.addItem("Split Light Blue");
blue_mom.addItem("Cobalt Blue");
blue_mom.addItem("Split Cobalt Blue");
blue_mom.addItem("Aquamarine");
add(blue_mom);
blue_mom.reshape(255, 40, 185, 20);
dark_dad = new Choice();
dark_dad.setBackground(groupcolor);
dark_dad.addItem("No Dark Factor");
dark_dad.addItem("Mid");
dark_dad.addItem("Full");
add(dark_dad);
dark_dad.reshape(5, 120, 185, 20);
dark_mom = new Choice();
dark_mom.setBackground(groupcolor);
dark_mom.addItem("No Dark Factor");
dark_mom.addItem("Mid");
dark_mom.addItem("Full");
add(dark_mom);
dark_mom.reshape(255, 120, 185, 20);
orange_ateam = new Choice();
orange_ateam.setBackground(groupcolor);
orange_ateam.addItem("Not Orange");
orange_ateam.addItem("Split Orange");
orange_ateam.addItem("Orange");
add(orange_ateam);
orange_ateam.reshape(5, 200, 185, 20);
orange_bteam = new Choice();
orange_bteam.setBackground(groupcolor);
orange_bteam.addItem("Not Orange");
orange_bteam.addItem("Split Orange");
orange_bteam.addItem("Orange");
add(orange_bteam);
orange_bteam.reshape(255, 200, 185, 20);
dv_dad = new Choice();
dv_dad.setBackground(groupcolor);
dv_dad.addItem("Not Lavender");
dv_dad.addItem("Mid Lavender)");
dv_dad.addItem("Full Lavender)");
add(dv_dad);
dv_dad.reshape(5, 240, 185, 20);
dv_mom = new Choice();
dv_mom.setBackground(groupcolor);
dv_mom.addItem("Not Lavender");
dv_mom.addItem("Mid Lavender)");
dv_mom.addItem("Full Lavender)");
add(dv_mom);
dv_mom.reshape(255, 240, 185, 20);
do_it = new Button("What Could I Get??");
do_it.setFont(new Font("Dialog", 1, 12));
add(do_it);
do_it.reshape(455, 40, 130, 50);
clear_form = new Button("Clear The Form");
clear_form.setFont(new Font("Dialog", 1, 12));
add(clear_form);
clear_form.reshape(455, 120, 130, 50);
male_sexlink = new List();
female_sexlink = new List();
sex = new List();
split_females = new List();
split_males = new List();
females = new List();
males = new List();
blue = new List();
darkfactor = new List();
piedfactor = new List();
orange = new List();
danish_violet = new List();
results = new List(10, false);
results.setBackground(color_white);
add(results);
results.preferredSize();
results.reshape(20, 305, 560, 175);
results.addItem("Enter Colors above.");
results.addItem("Press Results");
results.reshape(20, 305, 560, 175);
label4 = new Label("Instructions:");
add(label4);
label4.reshape(20, 285, 560, 20);
}

public boolean handleEvent(Event event)
{
if(event.id == 1001 && event.target == do_it)
{
clicked_do_it();
return true;
}
if(event.id == 1001 && event.target == clear_form)
{
clicked_clear_form();
return true;
} else
{
return super.handleEvent(event);
}
}

public void clicked_do_it()
{
results.clear();
sex.clear();
males.clear();
females.clear();
split_males.clear();
split_females.clear();
blue.clear();
male_sexlink.clear();
female_sexlink.clear();
darkfactor.clear();
piedfactor.clear();
orange.clear();
danish_violet.clear();
switch(dark_dad.getSelectedIndex())
{
case 0: // '\0'
if(dark_mom.getSelectedIndex() == 0)
darkfactor.addItem("");
else
if(dark_mom.getSelectedIndex() == 1)
{
darkfactor.addItem("");
darkfactor.addItem("Mid ");
} else
if(dark_mom.getSelectedIndex() == 2)
darkfactor.addItem("Mid ");
break;

case 1: // '\001'
if(dark_mom.getSelectedIndex() == 0)
{
darkfactor.addItem("");
darkfactor.addItem("Mid ");
} else
if(dark_mom.getSelectedIndex() == 1)
{
darkfactor.addItem("");
darkfactor.addItem("Mid ");
darkfactor.addItem("Dark ");
} else
if(dark_mom.getSelectedIndex() == 2)
{
darkfactor.addItem("Mid ");
darkfactor.addItem("Dark ");
}
break;

case 2: // '\002'
if(dark_mom.getSelectedIndex() == 0)
darkfactor.addItem("Mid ");
else
if(dark_mom.getSelectedIndex() == 1)
{
darkfactor.addItem("Mid ");
darkfactor.addItem("Dark ");
} else
if(dark_mom.getSelectedIndex() == 2)
darkfactor.addItem("Dark ");
break;
}
switch(dv_dad.getSelectedIndex())
{
case 0: // '\0'
if(dv_mom.getSelectedIndex() == 0)
danish_violet.addItem("");
else
if(dv_mom.getSelectedIndex() == 1)
{
danish_violet.addItem("");
danish_violet.addItem("Mid Lavender ");
} else
if(dv_mom.getSelectedIndex() == 2)
danish_violet.addItem("Mid Lavender ");
break;

case 1: // '\001'
if(dv_mom.getSelectedIndex() == 0)
{
danish_violet.addItem("");
danish_violet.addItem("Mid Lavender ");
} else
if(dv_mom.getSelectedIndex() == 1)
{
danish_violet.addItem("");
danish_violet.addItem("Mid Lavender ");
danish_violet.addItem("Full Lavender ");
} else
if(dv_mom.getSelectedIndex() == 2)
{
danish_violet.addItem("Mid Lavender ");
danish_violet.addItem("Full Lavender ");
}
break;

case 2: // '\002'
if(dv_mom.getSelectedIndex() == 0)
danish_violet.addItem("Mid Lavender ");
else
if(dv_mom.getSelectedIndex() == 1)
{
danish_violet.addItem("Mid Lavender ");
danish_violet.addItem("Full Lavender ");
} else
if(dv_mom.getSelectedIndex() == 2)
danish_violet.addItem("Full Lavender ");
break;
}
switch(pied_dad.getSelectedIndex())
{
case 0: // '\0'
if(pied_mom.getSelectedIndex() == 0)
piedfactor.addItem("");
else
if(pied_mom.getSelectedIndex() == 1)
{
piedfactor.addItem("");
piedfactor.addItem("Pied ");
}
break;

case 1: // '\001'
piedfactor.addItem("");
piedfactor.addItem("Pied ");
break;
}
switch(orange_ateam.getSelectedIndex())
{
case 0: // '\0'
if(orange_bteam.getSelectedIndex() == 0)
orange.addItem("");
else
if(orange_bteam.getSelectedIndex() == 1)
{
orange.addItem("");
orange.addItem("/Orange ");
} else
if(orange_bteam.getSelectedIndex() == 2)
orange.addItem("/Orange ");
break;

case 1: // '\001'
if(orange_bteam.getSelectedIndex() == 0)
{
orange.addItem("");
orange.addItem("/Orange ");
} else
if(orange_bteam.getSelectedIndex() == 1)
{
orange.addItem("");
orange.addItem("/Orange ");
orange.addItem("Orange ");
} else
if(orange_bteam.getSelectedIndex() == 2)
{
orange.addItem("/Orange ");
orange.addItem("Orange ");
}
break;

case 2: // '\002'
if(orange_bteam.getSelectedIndex() == 0)
orange.addItem("/Orange ");
else
if(orange_bteam.getSelectedIndex() == 1)
{
orange.addItem("/Orange ");
orange.addItem("Orange ");
} else
if(orange_bteam.getSelectedIndex() == 2)
orange.addItem("Orange ");
break;
}
switch(sexlink_dad.getSelectedIndex())
{
case 0: // '\0'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("");
female_sexlink.addItem("");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("/Yellow ");
female_sexlink.addItem("");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
female_sexlink.addItem("");
male_sexlink.addItem("/Gold ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
female_sexlink.addItem("");
male_sexlink.addItem("/Silver ");
}
break;

case 1: // '\001'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("");
male_sexlink.addItem("/Yellow ");
female_sexlink.addItem("");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("/Yellow ");
male_sexlink.addItem("Yellow ");
female_sexlink.addItem("");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("/Am. Cinn ");
male_sexlink.addItem("/Yellow AND /Silver ");
female_sexlink.addItem("");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("/Silver ");
male_sexlink.addItem("Golden Silver ");
female_sexlink.addItem("");
female_sexlink.addItem("Yellow ");
}
break;

case 2: // '\002'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("/Yellow ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("Yellow ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("/Yellow AND /Silver ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("Golden Silver ");
female_sexlink.addItem("Yellow ");
}
break;

case 3: // '\003'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("");
male_sexlink.addItem("/Gold ");
female_sexlink.addItem("");
female_sexlink.addItem("Gold ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("/Yellow ");
male_sexlink.addItem("/Yellow AND /Silver ");
female_sexlink.addItem("");
female_sexlink.addItem("Gold ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("/Silver ");
male_sexlink.addItem("Gold ");
female_sexlink.addItem("");
female_sexlink.addItem("Gold ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("/Silver ");
male_sexlink.addItem("/Silver AND /Silver ");
female_sexlink.addItem("");
female_sexlink.addItem("Gold ");
}
break;

case 4: // '\004'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("/Silver ");
female_sexlink.addItem("Gold ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("/Yellow AND /Silver ");
female_sexlink.addItem("Gold ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("Gold ");
female_sexlink.addItem("Gold ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("/Silver AND /Silver ");
female_sexlink.addItem("Gold ");
}
break;

case 5: // '\005'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("");
male_sexlink.addItem("/Silver ");
female_sexlink.addItem("");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("/Yellow ");
male_sexlink.addItem("Golden Silver ");
female_sexlink.addItem("");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("/Silver ");
male_sexlink.addItem("/Silver AND /Silver ");
female_sexlink.addItem("");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("/Silver ");
male_sexlink.addItem("Silver ");
female_sexlink.addItem("");
female_sexlink.addItem("Silver ");
}
break;

case 6: // '\006'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("/Silver ");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("Golden Silver ");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("/Silver AND /Silver ");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("Silver ");
female_sexlink.addItem("Silver ");
}
break;

case 7: // '\007'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("/Silver ");
male_sexlink.addItem("/Yellow ");
female_sexlink.addItem("Silver ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("Golden Silver ");
male_sexlink.addItem("Yellow ");
female_sexlink.addItem("Silver ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("/Silver AND /Silver ");
male_sexlink.addItem("/Yellow AND /Silver ");
female_sexlink.addItem("Silver ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("Golden Silver ");
male_sexlink.addItem("Silver ");
female_sexlink.addItem("Silver ");
female_sexlink.addItem("Yellow ");
}
break;

case 8: // '\b'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("/Silver ");
male_sexlink.addItem("/Yellow ");
female_sexlink.addItem("Gold ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("/Yellow AND /Silver ");
male_sexlink.addItem("Yellow ");
female_sexlink.addItem("Gold ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("Gold ");
male_sexlink.addItem("/Yellow AND /Silver ");
female_sexlink.addItem("Gold ");
female_sexlink.addItem("Yellow ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("/Silver AND /Silver ");
male_sexlink.addItem("Golden Silver ");
female_sexlink.addItem("Gold ");
female_sexlink.addItem("Yellow ");
}
break;

case 9: // '\t'
if(sexlink_mom.getSelectedIndex() == 0)
{
male_sexlink.addItem("/Silver ");
male_sexlink.addItem("/Silver ");
female_sexlink.addItem("Gold ");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 1)
{
male_sexlink.addItem("/Yellow AND /Silver ");
male_sexlink.addItem("Golden Silver ");
female_sexlink.addItem("Gold ");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 2)
{
male_sexlink.addItem("Gold ");
male_sexlink.addItem("/Silver AND /Silver ");
female_sexlink.addItem("Gold ");
female_sexlink.addItem("Silver ");
} else
if(sexlink_mom.getSelectedIndex() == 3)
{
male_sexlink.addItem("/Silver AND /Silver ");
male_sexlink.addItem("Silver ");
female_sexlink.addItem("Gold ");
female_sexlink.addItem("Silver ");
}
break;
}
switch(blue_dad.getSelectedIndex())
{
default:
break;

case 0: // '\0'
if(blue_mom.getSelectedIndex() == 0)
{
blue.addItem("");
break;
}
if(blue_mom.getSelectedIndex() == 1)
{
blue.addItem("/Light Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 2)
{
blue.addItem("");
blue.addItem("/Light Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 3)
{
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 4)
{
blue.addItem("");
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 5)
{
blue.addItem("/Light Blue ");
blue.addItem("/Cobalt Blue ");
}
break;

case 1: // '\001'
if(blue_mom.getSelectedIndex() == 0)
{
blue.addItem("/Light Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 1)
{
blue.addItem("Light Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 2)
{
blue.addItem("Light Blue ");
blue.addItem("/Light Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 3)
{
blue.addItem("Aquamarine ");
break;
}
if(blue_mom.getSelectedIndex() == 4)
{
blue.addItem("/Light Blue ");
blue.addItem("Aquamarine ");
break;
}
if(blue_mom.getSelectedIndex() == 5)
{
blue.addItem("Light Blue ");
blue.addItem("Aquamarine ");
}
break;

case 2: // '\002'
if(blue_mom.getSelectedIndex() == 0)
{
blue.addItem("");
blue.addItem("/Light Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 1)
{
blue.addItem("/Light Blue ");
blue.addItem("Light Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 2)
{
blue.addItem("");
blue.addItem("/Light Blue ");
blue.addItem("Light Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 3)
{
blue.addItem("Aquamarine ");
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 4)
{
blue.addItem("");
blue.addItem("/Light Blue ");
blue.addItem("Aquamarine ");
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 5)
{
blue.addItem("Light Blue ");
blue.addItem("Aquamarine ");
blue.addItem("/Light Blue ");
blue.addItem("/Cobalt Blue ");
}
break;

case 3: // '\003'
if(blue_mom.getSelectedIndex() == 0)
{
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 1)
{
blue.addItem("Aquamarine ");
break;
}
if(blue_mom.getSelectedIndex() == 2)
{
blue.addItem("Aquamarine ");
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 3)
{
blue.addItem("Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 4)
{
blue.addItem("/Cobalt Blue ");
blue.addItem("Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 5)
{
blue.addItem("Cobalt Blue ");
blue.addItem("Aquamarine ");
}
break;

case 4: // '\004'
if(blue_mom.getSelectedIndex() == 0)
{
blue.addItem("");
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 1)
{
blue.addItem("/Light Blue ");
blue.addItem("Aquamarine ");
break;
}
if(blue_mom.getSelectedIndex() == 2)
{
blue.addItem("");
blue.addItem("/Light Blue ");
blue.addItem("Aquamarine ");
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 3)
{
blue.addItem("/Cobalt Blue ");
blue.addItem("Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 4)
{
blue.addItem("");
blue.addItem("/Cobalt Blue ");
blue.addItem("Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 5)
{
blue.addItem("Cobalt Blue ");
blue.addItem("Aquamarine ");
blue.addItem("/Light Blue ");
blue.addItem("/Cobalt Blue ");
}
break;

case 5: // '\005'
if(blue_mom.getSelectedIndex() == 0)
{
blue.addItem("/Light Blue ");
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 1)
{
blue.addItem("Light Blue ");
blue.addItem("Aquamarine ");
break;
}
if(blue_mom.getSelectedIndex() == 2)
{
blue.addItem("Light Blue ");
blue.addItem("/Light Blue ");
blue.addItem("Aquamarine ");
blue.addItem("/Cobalt Blue ");
break;
}
if(blue_mom.getSelectedIndex() == 3)
{
blue.addItem("Cobalt Blue ");
blue.addItem("Aquamarine ");
break;
}
if(blue_mom.getSelectedIndex() == 4)
{
blue.addItem("Cobalt Blue ");
blue.addItem("/Cobalt Blue ");
blue.addItem("/Light Blue ");
blue.addItem("Aquamarine ");
break;
}
if(blue_mom.getSelectedIndex() == 5)
{
blue.addItem("Cobalt Blue ");
blue.addItem("Aquamarine ");
blue.addItem("Light Blue ");
}
break;
}
int male_sexlinkcount = male_sexlink.countItems();
int female_sexlinkcount = female_sexlink.countItems();
int bluecount = blue.countItems();
int dvcount = danish_violet.countItems();
int darkcount = darkfactor.countItems();
int piedcount = piedfactor.countItems();
int orangecount = orange.countItems();
int malecount = bluecount * darkcount * male_sexlinkcount * orangecount * piedcount * dvcount;
int femalecount = bluecount * darkcount * female_sexlinkcount * orangecount * piedcount * dvcount;
for(int i = 0; i < darkcount; i++)
{
for(int j = 0; j < malecount / darkcount; j++)
{
males.addItem(darkfactor.getItem(i));
split_males.addItem("");
}

for(int j = 0; j < femalecount / darkcount; j++)
{
females.addItem(darkfactor.getItem(i));
split_females.addItem("");
}

}

int male_get_number = 0;
int female_get_number = 0;
for(int i = 0; i < darkcount; i++)
{
for(int j = 0; j < orangecount; j++)
{
for(int k = 0; k < malecount / (darkcount * orangecount); k++)
{
if(orange.getItem(j).length() > 0)
if(orange.getItem(j).charAt(0) == '/')
split = true;
else
split = false;
if(split)
split_males.replaceItem(split_males.getItem(male_get_number) + orange.getItem(j), male_get_number++);
else
males.replaceItem(males.getItem(male_get_number) + orange.getItem(j), male_get_number++);
}

for(int k = 0; k < femalecount / (darkcount * orangecount); k++)
if(split)
split_females.replaceItem(split_females.getItem(female_get_number) + orange.getItem(j), female_get_number++);
else
females.replaceItem(females.getItem(female_get_number) + orange.getItem(j), female_get_number++);

}

}

male_get_number = 0;
female_get_number = 0;
for(int i = 0; i < darkcount; i++)
{
for(int j = 0; j < orangecount; j++)
{
for(int k = 0; k < bluecount; k++)
{
for(int l = 0; l < malecount / (darkcount * orangecount * bluecount); l++)
{
if(blue.getItem(k).length() > 0)
if(blue.getItem(k).charAt(0) == '/')
split = true;
else
split = false;
if(split)
split_males.replaceItem(split_males.getItem(male_get_number) + blue.getItem(k), male_get_number++);
else
males.replaceItem(males.getItem(male_get_number) + blue.getItem(k), male_get_number++);
}

for(int l = 0; l < femalecount / (darkcount * orangecount * bluecount); l++)
if(split)
split_females.replaceItem(split_females.getItem(female_get_number) + blue.getItem(k), female_get_number++);
else
females.replaceItem(females.getItem(female_get_number) + blue.getItem(k), female_get_number++);

}

}

}

male_get_number = 0;
female_get_number = 0;
for(int i = 0; i < darkcount; i++)
{
for(int j = 0; j < orangecount; j++)
{
for(int k = 0; k < bluecount; k++)
{
for(int l = 0; l < male_sexlinkcount; l++)
{
for(int m = 0; m < malecount / (darkcount * orangecount * bluecount * male_sexlinkcount); m++)
{
if(male_sexlink.getItem(l).length() > 0)
if(male_sexlink.getItem(l).charAt(0) == '/')
split = true;
else
split = false;
if(split)
split_males.replaceItem(split_males.getItem(male_get_number) + male_sexlink.getItem(l), male_get_number++);
else
males.replaceItem(males.getItem(male_get_number) + male_sexlink.getItem(l), male_get_number++);
}

}

for(int l = 0; l < female_sexlinkcount; l++)
{
for(int m = 0; m < femalecount / (darkcount * orangecount * bluecount * female_sexlinkcount); m++)
{
if(female_sexlink.getItem(l).length() > 0)
if(female_sexlink.getItem(l).charAt(0) == '/')
split = true;
else
split = false;
if(split)
split_females.replaceItem(split_females.getItem(female_get_number) + female_sexlink.getItem(l), female_get_number++);
else
females.replaceItem(females.getItem(female_get_number) + female_sexlink.getItem(l), female_get_number++);
}

}

}

}

}

male_get_number = 0;
female_get_number = 0;
for(int i = 0; i < darkcount; i++)
{
for(int j = 0; j < orangecount; j++)
{
for(int k = 0; k < bluecount; k++)
{
for(int l = 0; l < male_sexlinkcount; l++)
{
for(int m = 0; m < dvcount; m++)
{
for(int n = 0; n < malecount / (darkcount * orangecount * bluecount * male_sexlinkcount * dvcount); n++)
males.replaceItem(males.getItem(male_get_number) + danish_violet.getItem(m), male_get_number++);

}

}

for(int l = 0; l < female_sexlinkcount; l++)
{
for(int m = 0; m < dvcount; m++)
{
for(int n = 0; n < femalecount / (darkcount * orangecount * bluecount * female_sexlinkcount * dvcount); n++)
females.replaceItem(females.getItem(female_get_number) + danish_violet.getItem(m), female_get_number++);

}

}

}

}

}

male_get_number = 0;
female_get_number = 0;
for(int i = 0; i < darkcount; i++)
{
for(int j = 0; j < orangecount; j++)
{
for(int k = 0; k < bluecount; k++)
{
for(int l = 0; l < male_sexlinkcount; l++)
{
for(int m = 0; m < dvcount; m++)
{
for(int n = 0; n < piedcount; n++)
{
for(int o = 0; o < malecount / (darkcount * orangecount * bluecount * male_sexlinkcount * dvcount * piedcount); o++)
males.replaceItem(males.getItem(male_get_number) + piedfactor.getItem(n), male_get_number++);

}

}

}

for(int l = 0; l < female_sexlinkcount; l++)
{
for(int m = 0; m < dvcount; m++)
{
for(int n = 0; n < piedcount; n++)
{
for(int o = 0; o < femalecount / (darkcount * orangecount * bluecount * female_sexlinkcount * dvcount * piedcount); o++)
females.replaceItem(females.getItem(female_get_number) + piedfactor.getItem(n), female_get_number++);

}

}

}

}

}

}

for(int i = 0; i < males.countItems(); i++)
{
if(males.getItem(i).length() < 3)
males.replaceItem(males.getItem(i) + "Normal Green ", i);
else
if(males.getItem(i).equals("Mid ") || males.getItem(i).equals("Dark "))
males.replaceItem(males.getItem(i) + "Green ", i);
results.addItem("Male " + males.getItem(i) + split_males.getItem(i));
}

for(int i = 0; i < females.countItems(); i++)
{
if(females.getItem(i).length() < 3)
females.replaceItem(females.getItem(i) + "Normal Green ", i);
else
if(females.getItem(i).equals("Mid ") || females.getItem(i).equals("Dark "))
females.replaceItem(females.getItem(i) + "Green ", i);
results.addItem("Female " + females.getItem(i) + split_females.getItem(i));
}

label4.setText(" This pair could produce " + results.countItems() + " distinct combinations. (Splits may not be visible)");
}

public void clicked_clear_form()
{
results.clear();
results.addItem("Describe the parents using the choices above.");
results.addItem("Press the button at top right to determine possible offspring");
blue_dad.select(0);
blue_mom.select(0);
pied_dad.select(0);
pied_mom.select(0);
dark_dad.select(0);
dark_mom.select(0);
dv_dad.select(0);
dv_mom.select(0);
orange_ateam.select(0);
orange_bteam.select(0);
sexlink_dad.select(0);
sexlink_mom.select(0);
label4.setText("Instructions:");
}

public teams()
{
}

InputStream xcounter;
DataInputStream xcounter_data;
OutputStream xcounter_out;
DataInputStream xcounter_data_out;
Label label1;
Label label2;
Label label3;
Choice blue_dad;
Choice blue_mom;
Choice pied_dad;
Choice pied_mom;
Choice dark_dad;
Choice dark_mom;
Choice dv_dad;
Choice dv_mom;
Choice orange_ateam;
Choice orange_bteam;
Choice sexlink_dad;
Choice sexlink_mom;
Button do_it;
Button clear_form;
List results;
List sex;
List males;
List females;
List split_males;
List split_females;
List male_sexlink;
List female_sexlink;
List blue;
List darkfactor;
List piedfactor;
List orange;
List danish_violet;
boolean switch_key;
boolean split;
Label label4;
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!