Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ListField arrayindex out of bounds exception

 
adroit dhanwada
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i created ListField in blackberry jde.
ListField list=new ListField(4);
if i say :
list.insert(0);
it is giving ArrayIndexOutofBounds exception.iam not calling callback.insert() method also(i commented it).can someone help with this please.is CLDC based applications complex to develop?
Thanks
 
Sayan Jaipan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try this

ObjectListField olf = ObjectListField() ;
olf.set(new String[]{"1", "2"});
 
adroit dhanwada
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou for the reply.
nope its not working. the error is after calling list.setCallback();,the class implementing the interface ListFieldCallback interface is initialised,then the method :
public void drawListRow(ListField list, Graphics g, int index, int y, int w)
{
String text = (String)listElement.elementAt(index);
g.drawText(text, 0, y, 0, w);
} is being called.
listElement is a java.util.Vector.
here listElement.elementAt(index) is giving ArrayIndexOutOfBoundsException
in the tutorial also the code is exactly like this.
regards
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!