|
-
September 10th, 2008, 07:40 PM
#3
Re: JComboBox AddItem
@Norm, the combobox object was created during the initialization and is used during insertion of items to it.
Right , Ive noticed that the behavior of addItems is inconsistent.
this is how the original code looks like
Code:
ArrayList<ParameterBean> beanList= new ArrayList<ParamaterBean>();
beanList= getListNames(); // this will return all names retrieve from the DB
if( beanList.size() > 0 )
{
//get each item from the list and insert to the comboBox using addItems
}
else
{
// set a temporary value to combobox
String strTemp = new String("DB Is Empty " );
this.comboDataList.addItem(strTemp)
}
the else part will cause an exception. In "ParameterBean" , I have a getName() function that returns a String. So for each Parameter, I insert the String value using addItem to the ComboBox and no Problems. But I explicitly insert a String like the one in ELSE part, it will cause and exception.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|