Switch to full style
Graphics and animation Java code examples
Post a reply

Choice choiceList popup list of choices

Sat Feb 09, 2013 4:34 pm

Choice choiceList popup list of choices
java code
import java.awt.*;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.applet.Applet;

public class ChoiceExample extends Applet
implements ItemListener {
Choice choiceList; //popup list of choices
Label labelObj;

public void init() {
choiceList = new Choice();
choiceList.addItem("A1");
choiceList.addItem("B1");
choiceList.addItem("C1");
choiceList.addItem("D1");

choiceList.addItemListener(this);

labelObj = new Label();
setLabelText(choiceList.getSelectedIndex(),
choiceList.getSelectedItem());

//Add components to the Applet.
add(choiceList);
add(labelObj);
}

void setLabelText(int num, String text) {
labelObj.setText("Item #" + num + " selected. "
+ "Text = \"" + text + "\".");
}

public void itemStateChanged(ItemEvent e) {
setLabelText(choiceList.getSelectedIndex(),
choiceList.getSelectedItem());
}
}




Post a reply
  Related Posts  to : Choice choiceList popup list of choices
 problem with binding a choice model with jaxb     -  
 Popup message without using javascript     -  
 Show popup dialog using JQuery     -  
 Popup message using JavaScript without using alert function     -  
 display list     -  
 list and explode     -  
 iterator on list     -  
 reverse list     -  
 List C++ implementation     -  
 list swap in C++     -  

Topic Tags

Java AWT, Java Applet