[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Resetting Items In JComboBox?



Title:

Hello,

I am having a problem with JComboBox. I am attempting to reset the item list during excution of the program by using removeAllItems() method followed by addItem() method.  However, the addItem() method bombs with an exception (I cannot tell what type of exception was generated because it scrolls off the WIN98 DOS console).  After, the exception is generated my JComboBox ActionListener stops working?

It seemed to be straight forward to reset the JComboBox with the above methods, obviously, I am doing something wrong. I have included a code snippet to help illustrate what I am attempting to achieve.  Any suggestions?  Thanks in advance.

Take It Easy,
D. Michael Nelson


JComboBox m_AnnotationCB

private void setAnnotationCB(Address address)
{
 m_AnnotationCB.removeAllItems();
 m_AnnotationCB.addItem((Object)"New");---->generates an exception?

 Vector annotationVectors = m_annotationSB.getAnnotationsForAddress(address.getAddressID());

 if (annotationVectors.size() > 0)
 {
  Iterator annotationIterator = annotationVectors.iterator();
  m_rgAnnotations = new AddressService.Annotation[annotationVectors.size()];
  int iIndex = 0;
  while (annotationIterator.hasNext())
  {
    m_rgAnnotations[iIndex++1] = (AddressService.Annotation)annotationIterator.next();
    System.out.println(m_rgAnnotations[iIndex-1].getAnnotation());
    m_AnnotationCB.addItem(m_dateFormat.format(m_rgAnnotations[iIndex].getLastUpdatedDate()));
    The above line does not work?                     
 
}
 }
}