-
what's wrong ??
hi,
all i want to do is just to get the selected content in List A and move them to List B
and i end up this piece of code b4 i can compile successfully.
int[] selectedData ;
Object[] objData ;
String cmd = e.getActionCommand();
if( cmd.equals( "hide" ) == true )
{
selectedData = regtrList.getSelectedIndices() ;
objData = new Object[selectedData.length] ;
for (int i=0; i<selectedData.length; i++)
objData[i] = Integer.toString(selectedData[i]) ;
filterList.setListData(objData) ;
}
any1 dare to tell me what stupid mistake i made here ?
thank u
Signature (up to 100 characters) You may use Markup in your signature
-
Re: what's wrong ??
The only thing I can see wrong right now is that you're trying to take an array (the whole array, not each element) and output it as a string. To fix this, change the following line:
objData = Integer.toString(selectedData);
to
objData = Integer.toString(selectedData[i]);
-------------------------------------------
weaver
icq# 64665116
Please rate this post.
http://weaver.x7.htmlplanet.com
-
Re: what's wrong ??
When you post a question , please explain your problem clearly. Are u getting any compiler
or runtime error ? Or are u getting unwanted result ???
> for (int i=0; i<selectedData.length; i++)
> objData = Integer.toString(selectedData) ;
I dont know whether it's codeguru forum site bug or you are actually trying to do this.
( dont use "["i"]" , it will be interpreted as "<"i">" tag in HTML )
If your code is something like the following,
for (int index=0; index<selectedData.length; index++)
objData[index] = Integer.toString(selectedData[index]) ;
You are trying to assign the indexes not the values from the "regtrList". If you want
the values , you have to do something like the following
objData[index] = regtrList.getItem().(selectedData[index]) ;
Poochi..