import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Start extends Applet implements ActionListener { static Choice crossChoice; static int cross; static char generation; static Font font1, font2, font3; private CrossFrame f; private Answer a; private Button crossP, crossF1, checkButton; private Label chooseCross, checkLabel1, checkLabel2, blank; private TextField checkField1, checkField2; private Panel p, p1; static public Image M_Sepia_Wing_AlbinoGif, F_Sepia_Wing_AlbinoGif, M_Red_Wing_AlbinoGif, F_Red_Wing_AlbinoGif, F_White_Wing_AlbinoGif, M_White_Wing_AlbinoGif, F_Red_Vest_AlbinoGif, M_Red_Vest_AlbinoGif, F_Sepia_Vest_AlbinoGif, M_Sepia_Vest_AlbinoGif, F_Red_Wing_EbonyGif, M_Red_Wing_EbonyGif, F_Red_Vest_EbonyGif, M_Red_Vest_EbonyGif; public void init() { M_Sepia_Wing_AlbinoGif = getImage( getDocumentBase(), "M_Sepia_Wing_Albino.gif" ); F_Sepia_Wing_AlbinoGif = getImage( getDocumentBase(), "F_Sepia_Wing_Albino.gif" ); M_Red_Wing_AlbinoGif = getImage( getDocumentBase(), "M_Red_Wing_Albino.gif" ); F_Red_Wing_AlbinoGif = getImage( getDocumentBase(), "F_Red_Wing_Albino.gif" ); F_Red_Wing_AlbinoGif = getImage( getDocumentBase(), "F_Red_Wing_Albino.gif" ); M_Red_Wing_AlbinoGif = getImage( getDocumentBase(), "M_Red_Wing_Albino.gif" ); F_White_Wing_AlbinoGif = getImage( getDocumentBase(), "F_White_Wing_Albino.gif" ); M_White_Wing_AlbinoGif = getImage( getDocumentBase(), "M_White_Wing_Albino.gif" ); F_Red_Wing_AlbinoGif = getImage( getDocumentBase(), "F_Red_Wing_Albino.gif" ); M_Red_Wing_AlbinoGif = getImage( getDocumentBase(), "M_Red_Wing_Albino.gif" ); F_Red_Vest_AlbinoGif = getImage( getDocumentBase(), "F_Red_Vest_Albino.gif" ); M_Red_Vest_AlbinoGif = getImage( getDocumentBase(), "M_Red_Vest_Albino.gif" ); F_Sepia_Wing_AlbinoGif = getImage( getDocumentBase(), "F_Sepia_Wing_Albino.gif" ); M_Sepia_Wing_AlbinoGif = getImage( getDocumentBase(), "M_Sepia_Wing_Albino.gif" ); F_Sepia_Vest_AlbinoGif = getImage( getDocumentBase(), "F_Sepia_Vest_Albino.gif" ); M_Sepia_Vest_AlbinoGif = getImage( getDocumentBase(), "M_Sepia_Vest_Albino.gif" ); F_Red_Wing_AlbinoGif = getImage( getDocumentBase(), "F_Red_Wing_Albino.gif" ); M_Red_Wing_AlbinoGif = getImage( getDocumentBase(), "M_Red_Wing_Albino.gif" ); F_Red_Vest_AlbinoGif = getImage( getDocumentBase(), "F_Red_Vest_Albino.gif" ); M_Red_Vest_AlbinoGif = getImage( getDocumentBase(), "M_Red_Vest_Albino.gif" ); F_Red_Wing_EbonyGif = getImage( getDocumentBase(), "F_Red_Wing_Ebony.gif" ); M_Red_Wing_EbonyGif = getImage( getDocumentBase(), "M_Red_Wing_Ebony.gif" ); F_Red_Vest_EbonyGif = getImage( getDocumentBase(), "F_Red_Vest_Ebony.gif" ); M_Red_Vest_EbonyGif = getImage( getDocumentBase(), "M_Red_Vest_Ebony.gif" ); int align = FlowLayout.CENTER; p = new Panel(); p.setLayout( new GridLayout(3,4,5, 5) ); font1 = new Font( "Serif", Font.BOLD, 18); font2 = new Font( "SansSerif", Font.BOLD + Font.ITALIC, 12); font3 = new Font( "Serif", Font.BOLD, 14); this.setBackground(Color.white); chooseCross = new Label("Choose a Cross"); crossChoice = new Choice(); crossChoice.add( "1" ); crossChoice.add( "2" ); crossChoice.add( "3" ); crossChoice.add( "4" ); crossP = new Button( "Cross P Flies" ); crossP.addActionListener( this ); crossF1 = new Button( "Cross F1 Flies" ); crossF1.addActionListener( this ); checkLabel1 = new Label( "Enter Genotype"); checkField1 = new TextField(10); checkField1.setText("XXRRWWBB"); checkButton = new Button("Check Genotype"); checkButton.addActionListener( this ); checkLabel2 = new Label( "Enter Genotype"); checkField2 = new TextField(10); checkField2.setText("XXRRWWBB"); blank = new Label(""); p.add( chooseCross ); p.add( crossChoice); p.add( crossP ); p.add( crossF1 ); p.add ( checkLabel1 ); p.add( checkField1 ); p.add( blank ); p.add( checkButton ); p.add ( checkLabel2 ); p.add( checkField2 ); setLayout( new BorderLayout()); add( p, BorderLayout.SOUTH); } public void paint( Graphics g) { int x = 25; g.setColor(Color.blue); g.setFont(font1); g.drawString("Drosophilia Intro Biology Lab", 5, x); g.setColor(Color.red); g.setFont(font2); g.drawString("1. Choose the cross below", 15, x += 15); g.drawString("2. Click Cross P Flies", 15, x += 15); g.drawString("3. Count and record the F1 generation flies", 15, x += 15); g.drawString("4. Repeat steps 2 and 3 and count the F2 generation", 15, x += 15); g.drawString("5. When you have figured out the genotypes of", 15, x += 15); g.drawString(" the parents enter them below", 15, x += 15); g.drawString(" they must be in the format XXRRWWBB", 15, x += 15); } public void actionPerformed( ActionEvent e ) { cross = (crossChoice.getSelectedIndex() + 1); validate(); if (e.getActionCommand() == "Cross P Flies") { generation = 'P'; f = new CrossFrame(this, "Cross Parents", generation, cross); f.setVisible( true ); // show the frame } else if (e.getActionCommand() == "Cross F1 Flies") { generation = 'F'; f = new CrossFrame(this, "Cross F1 Flies", generation, cross); f.setVisible( true ); // show the frame } else if (e.getActionCommand() == "Check Genotype") { String answer1 = checkField1.getText(); String answer2 = checkField2.getText(); f = new CrossFrame(this, "Cross Parents", 'P', cross); f.setVisible( false ); showStatus("" + f.AllheleOne); showStatus("" + f.AllheleTwo); a = new Answer("Answer", answer1, f.AllheleOne, answer2, f.AllheleTwo); a.setVisible( true ); /*if (answer1.equals(f.AllheleOne) | answer2.equals(f.AllheleOne)) showStatus("Yes"); else showStatus("No"); if (answer1.equals(f.AllheleTwo) | answer2.equals(f.AllheleTwo)) showStatus("Yes"); else showStatus("No"); */ } } }