//****************************************************************//
//                                                                //
// class Vocabulary                                               //
//        was programmed by Etsuko with Visual J++ 1.1 (JDK 1.02) //
//                                                                //
//****************************************************************//

import java.applet.*;
import java.awt.*;

public class Vocabulary extends Applet{
    
    String quizNumber_p;//question numbers from parameter
    String question_p[];//questions from parameter
    String ansJ_p[];    //answers(Japanese) from parameter
    String ansR_p[];    //answers(Romaji) from parameter
    String fontA_p;     //font size for answer from parameter
    String fontQ_p;     //font size for question from parameter
    String message_p;   //answerPanel message from parameter

    int quizNumber;             //quiz number
    int fontSizeA, fontSizeQ;   //font size

    Panel quizPanel  = new Panel();     //panel for questions
    Panel soundPanel = new Panel();     //panel for sound on/ff
    Panel sellectPanel = new Panel();   //language select panel
    Panel sellectAllPanel = new Panel();//panel for select language
    Panel answerPanel = new Panel();    //panel for answers

    Button q[];
    Label answerMessage;
    CheckboxGroup cbg;  //checkbox for selecting answer language
    Checkbox kanjiCB;
    Checkbox romajiCB;
    Checkbox soundCB;
    AudioClip sound1;   //sound

    public void init(){ 
    
        sound1 = getAudioClip(getDocumentBase(), "./1.au");
        setLayout(new BorderLayout());
        questionPanelSetting();
        answerPanelSetting();
        lowerPanelSetting();
        
    }


//---------------------- answer panel setting---------------------------//

    public void answerPanelSetting(){
        
        fontA_p = getParameter("Afont");    //get font size from parameter
        if(fontA_p == null)fontA_p = "15";
        fontSizeA = Integer.parseInt(fontA_p);
        ansJ_p = new String[quizNumber];    
        ansR_p = new String[quizNumber];    

        for(int n =0; n<quizNumber; n++){   //get answers from parameter
            ansJ_p[n] = getParameter("answer_j"+(n+1));
            if(ansJ_p[n] == null){ansJ_p[n] = "Error";}
            ansR_p[n] = getParameter("answer_r"+(n+1));
            if(ansR_p[n] == null){ansR_p[n] = "Error";}
        }

        message_p = getParameter("message");
        if(message_p == null){message_p = "Please click a button below.";}

        Font ansF = new Font("Dialog", Font.PLAIN, fontSizeA);
        answerMessage = new Label(message_p);
        answerMessage.setFont(ansF);
        answerMessage.setBackground(Color.black);
        answerMessage.setForeground(Color.white);

        answerPanel.add(answerMessage);
        answerPanel.setBackground(Color.black);
        add("South", sellectAllPanel);
        add("North", answerPanel);
        
    }


//---------------- question panel setting ----------------------------//

    public void questionPanelSetting(){
        
        add("Center", quizPanel);
        quizPanel.setBackground(Color.darkGray);       
        fontQ_p = getParameter("Qfont");    //get font size from parameter
        if(fontQ_p == null)fontQ_p = "15";
        fontSizeQ = Integer.parseInt(fontQ_p);
        Font quizF = new Font("Dialog", Font.PLAIN, fontSizeQ);
        quizPanel.setFont(quizF);

        quizNumber_p = getParameter("maxQuizNum");  //get question number from parameter
        if(quizNumber_p == null)quizNumber_p = "1";
        quizNumber = Integer.parseInt(quizNumber_p);

        quizPanel.setLayout(new GridLayout(quizNumber,1));
        q = new Button[quizNumber];
        question_p = new String[quizNumber];
    
        for(int n =0; n<quizNumber; n++){       //get questions from parameter
            question_p[n] = getParameter("question_"+(n+1));
            if(question_p[n] == null){question_p[n] = "Error";}
            q[n] = new Button(""+question_p[n]);
            quizPanel.add(q[n]);
        }
    }


//----------- answer language select and sound panel setting -----------//

    public void lowerPanelSetting(){
        
        soundPanel.setBackground(Color.darkGray);       
        sellectPanel.setBackground(Color.darkGray);       
        sellectPanel.setLayout(new GridLayout(1,2));
        cbg = new CheckboxGroup();
        kanjiCB = new Checkbox("漢字/かな", cbg, true);
        romajiCB = new Checkbox("Romaji", cbg, false);
        kanjiCB.setBackground(Color.darkGray);
        romajiCB.setBackground(Color.darkGray);
        kanjiCB.setForeground(Color.white);
        romajiCB.setForeground(Color.white);
        sellectPanel.setFont(new Font("Dialog", Font.PLAIN, 17));
        sellectPanel.add(kanjiCB);
        sellectPanel.add(romajiCB);

        soundCB = new Checkbox("sound on/off");
        soundCB.setState(true);
        soundCB.setBackground(Color.darkGray);
        soundCB.setForeground(Color.white);
        soundPanel.setFont(new Font("Dialog", Font.PLAIN, 17));
        soundPanel.add(soundCB);

        sellectAllPanel.setLayout(new GridLayout(1,2));
        sellectAllPanel.add(sellectPanel);
        sellectAllPanel.add(soundPanel);
        
    }


//------------- Action when a button was pushed ------------------------//

    public boolean action(Event e, Object o){
        
        if(e.target instanceof Button){ //if sound box is checked play sound
            if(soundCB.getState() == true){
                sound1.play();
            }
    
    //show answers in Nihongo or Romaji according to the selected language
            if(cbg.getCurrent().equals(kanjiCB)){
                for(int k=0; k<quizNumber; k++){
                    if(q[k].getLabel().equals(o)){
                        answerMessage.setText(ansJ_p[k]);
                    }
                }
            }
        
            if(cbg.getCurrent().equals(romajiCB)){
                for(int k=0; k<quizNumber; k++){
                    if(q[k].getLabel().equals(o)){
                        answerMessage.setText(ansR_p[k]);
                    }
                }
            }
        }
        return true;
    }
    
}
///-----

Applet code and parameters(example) in HTML file.
<applet code=Vocabulary width=400 height=360>

<param name=Afont value=21>      <!font size for answer>
<param name=Qfont value=20>      <!font size for question>
<param name=maxQuizNum value=10> <!question number>
<param name=message value="Please click an expression below!">
                                    <! instruction message>

<!questions>
<param name=question_1 value="Well, yes and no.">
<param name=question_2 value="Is anything wrong?">
<param name=question_3 value="take care of the dog">
<param name=question_4 value="I'm allergic to cat hair.">
<param name=question_5 value="house pet">
<param name=question_6 value="stray cat">
<param name=question_7 value="limp">
<param name=question_8 value="get hit by a car">
<param name=question_9 value="howl">
<param name=question_10 value="sniff">

<!answers in Nihongo>
<param name=answer_j1 value="そうも言えるし逆も言えます。">
<param name=answer_j2 value="どうかしましたか?">
<param name=answer_j3 value="その犬の世話をする">
<param name=answer_j4 value="猫の毛にアレルギーです。">
<param name=answer_j5 value="家で飼っているペット">
<param name=answer_j6 value="野良猫">
<param name=answer_j7 value="足を引きずって歩く">
<param name=answer_j8 value="車にはねられる">
<param name=answer_j9 value="遠吠えする">
<param name=answer_j10 value="鼻をすすり上げる">

<!answers in Romaji>
<param name=answer_r1 value="Soumo ierushi gyakumo iemasu.">
<param name=answer_r2 value="Douka shimashitaka?">
<param name=answer_r3 value="sono inu no sewa o suru">
<param name=answer_r4 value="Neko no ke ni arerugii desu.">
<param name=answer_r5 value="ie de katteiru petto">
<param name=answer_r6 value="nora-neko">
<param name=answer_r7 value="ashi o hikizutte aruku">
<param name=answer_r8 value="kuruma ni hane-rareru">
<param name=answer_r9 value="tooboe suru">
<param name=answer_r10 value="hana o susuri ageru">

</applet>


BACK