a mi se me ocurre lo siguiente :
//Creo unos contadores
public Integer w98=0,wxp=0,linux=0;
//Tengo un choice
choice1 = new java.awt.Choice();
choice1.add("Elige Sistema Operativo");
choice1.add("Windows 98");
choice1.add("Windows XP");
choice1.add("Linux");
//Evento al cambiar de estado un elemento del choice
private void choice1ItemStateChanged(java.awt.event.ItemEvent evt) {
if (choice1.getSelectedItem()=="Windows 98") {w98++;}
if (choice1.getSelectedItem()=="Windows XP") {wxp++;}
if (choice1.getSelectedItem()=="Linux") {linux++;}
}
Lo he probado con el siguiente ejemplo implementado en NetBeans
Código:
/*
* Ejemplo.java
*
* Created on 21 de enero de 2006, 4:53
*/
package general;
/**
*
* @author DogDuck
*/
public class Ejemplo extends javax.swing.JFrame {
public Integer w98=0,wxp=0,linux=0;
/** Creates new form Ejemplo */
public Ejemplo() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
choice1 = new java.awt.Choice();
choice1.add("Elige Sistema Operativo");
choice1.add("Windows 98");
choice1.add("Windows XP");
choice1.add("Linux");
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
getContentPane().setLayout(null);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
choice1.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
choice1ItemStateChanged(evt);
}
});
getContentPane().add(choice1);
choice1.setBounds(30, 30, 210, 20);
jLabel1.setText("w98");
getContentPane().add(jLabel1);
jLabel1.setBounds(40, 80, 30, 14);
jLabel2.setText("wxp");
getContentPane().add(jLabel2);
jLabel2.setBounds(40, 110, 30, 14);
jLabel3.setText("linux");
getContentPane().add(jLabel3);
jLabel3.setBounds(40, 140, 30, 14);
jTextField1.setText("0");
getContentPane().add(jTextField1);
jTextField1.setBounds(90, 80, 12, 20);
jTextField2.setText("0");
getContentPane().add(jTextField2);
jTextField2.setBounds(90, 110, 12, 20);
jTextField3.setText("0");
getContentPane().add(jTextField3);
jTextField3.setBounds(90, 140, 12, 20);
pack();
}// </editor-fold>
private void choice1ItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
if (choice1.getSelectedItem()=="Windows 98") {w98++;jTextField1.setText(w98.toString());}
if (choice1.getSelectedItem()=="Windows XP") {wxp++;jTextField2.setText(wxp.toString());}
if (choice1.getSelectedItem()=="Linux") {linux++;jTextField3.setText(linux.toString());}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Ejemplo().setVisible(true);
}
});
}
// Variables declaration - do not modify
private java.awt.Choice choice1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration
}
Espero te valga de algo