if(item.isSelected()){
box.setSelectedItem(item);
break;
}
}
box.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
Action action = (Action) value;
Icon icon = (Icon)action.getValue(Action.SMALL_ICON);
String text = (String)action.getValue(Action.NAME);
Object renderedValue = text == null ? icon : text;
DefaultListCellRenderer renderer = (DefaultListCellRenderer) super.getListCellRendererComponent(list, renderedValue, index, isSelected, cellHasFocus);
if(text != null && icon != null)
renderer.setIcon(icon);
return renderer;
}
});
box.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {