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

RE: Resetting Items In JComboBox?



Title:
Try temporarily wrapping all of the code with a try/catch block for Exception, and then print out the exception message.  The message may give some hints as to what's causing the exception:
 
private void setAnnotationCB(Address address)
{
 
    try
    {
 

 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?                     
 
}
 }
 
    }
        catch ( Exception e )
        {
            System.out.println( "Exception thrown in setAnnotationCB(): " + e.getMessage() );
        }
}
 
HTH,
 
Pros
 
-----Original Message-----
From: D. Michael Nelson [mailto:dmn1@bellsouth.net]
Sent: Wednesday, August 08, 2001 6:20 PM
To: Eos; Ajug
Subject: Resetting Items In JComboBox?
Importance: High

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?                     
 
}
 }
}