Problem With jList
Hello every one I want to add element in jList by returning database and collect in a String array.
but wahen i add element like jList.addElement(string[i]);
it gives error. here i is for loop variable.
The same thing work fine with jComboBox;.addItem(string[i]);
Please tell me where is the problem and what is method i have to use.
I dont know much about the JList, I've never used it.
I did have a brief look at the java docs, and it looks like you should add the list of strings in the constructor:
No need for any loops :)
JList aList = new JList (string);
Alternatively it looks like you could use
As I said I've never used JList before so I may be wrong.
Hope this helps!
It would help greatly if you were to show more of your code and show the exact error message. Otherwise all we can do is guess what is wrong.
Originally Posted by amitabh
Thank y sir
Originally Posted by berkeleybross
your code aList.setListData(string); is working correctly and my problem has been solved