Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Need help with ArrayList

  Asked By: Gerritt    Date: Jan 04    Category: Java    Views: 715
  

I need to extract the string elements in an ArrayList and add them
individually to the cCombobox. I'm having a lot of trouble with
this.
---- Code ------

DirChecker myChecker = new DirChecker();
ArrayList showList = new ArrayList();//
showList = myChecker.show();//This method returns the files in the
directory


Object[] cObject = {showList.toString()};// I get all the
files in this format -[file1,file2,file3].

cComboBox = new JComboBox(cObject);
cComboBox.addActionListener(this);
mySecondPanel.add(cComboBox);
this.getContentPane().add(mySecondPanel,BorderLayout.WEST);

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Kay Rodriguez     Answered On: Jan 04

If you want to obtain an Object array from an
ArrayList, you have to do this:

Object[] cObject = showList.toArray();

 
Didn't find what you were looking for? Find more on Need help with ArrayList Or get search suggestion and latest updates.




Tagged: