/**
*
*/
package de.tutorials;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.accessibility.AccessibleContext;
import javax.swing.JComboBox;
import javax.swing.JFrame;
/**
* @author daritho
*
*/
public class ComboBoxExample extends JFrame {
public ComboBoxExample() {
super("ComboBoxExample");
setDefaultCloseOperation(EXIT_ON_CLOSE);
final JComboBox comboBox = new JComboBox(new Object[] { "a", "b", "c",
"d", "e" });
comboBox.getAccessibleContext().addPropertyChangeListener(
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(
"AccessibleActiveDescendant")) {
System.out.println(comboBox
.getItemAt(((AccessibleContext) evt
.getNewValue())
.getAccessibleIndexInParent()));
}
}
});
add(comboBox);
pack();
setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
new ComboBoxExample();
}
}