Java. What to do with Choice()???

Posted by modzo on Stack Overflow See other posts from Stack Overflow or by modzo
Published on 2010-03-20T20:46:41Z Indexed on 2010/03/20 20:51 UTC
Read the original article Hit count: 72

Filed under:
|

import java.awt.*;

import java.awt.event.*;

import java.applet.*;

public class ChoiceSample extends Applet implements ActionListener, ItemListener {

Choice dz2;
public void init(){
    dz2 = new Choice();
    dz2.addItem("female");
    dz2.addItem("male");
    dz2.addItemListener(this);
    add(dz2);

public void itemStateChanged(ItemEvent e) {

String result = dz2.getSelectedItem();
repaint();
    if(result.equals(getParameter("male"))){ 
        dz1 = 0.5;
    }
    else{
        dz1 = 0.7;
   }

} }

/* this is yust a fragment from my program but this is the only thing that I can`t make right. I need when I chose male -> dz1 = 0.5, but when I chose female dz1 = 0.7 Can someone help me, please? */

© Stack Overflow or respective owner

Related posts about javascript-events

Related posts about applet