Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String to Object?

Status
Not open for further replies.

wangdong

Programmer
Oct 28, 2004
202
CN
I want to add values into a combobox.

Code:
defaultComboBoxModel = new DefaultComboBoxModel();
String boardType[] = {"AAA","VBB","sdfa","aaa","e"};
for(int i=0;i<boardType.length;i++){
  defaultComboBoxModel.add(boardType[i]);
}

It gives me the following error:
The method add(String) is undefined for the type DefaultComboBoxModel

Any idea?
 
I found an alternative way to do it.

Code:
  String combItem[] ={"AA", "BB");
  JComboBox combTemp = new JCombBox(combItem);
 
You could also use the addElement method to add a single String.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top