Hey there,
i've got a problem, and i don't know why... i try to explain my little problem:
i've got a ListField with a listcallback (
ListCallback2), a vector (named
_messages) of my own Class
MyOrder. Now I want to draw all Items of the Vector into the ListField. Here is some of my sourcecode:
MyOrder-Class PHP Code:
public class MyOrder {
private int status;
private String ursprung;
//...
mainScreen with the ListCallback and ListField PHP Code:
private static Vector _messages;
public static ListField _listField;
public static ListCallback2 callback;
//...
_listField = new ListField();
callback = new ListCallback2();
_listField.setCallback(callback);
//...
public static MyOrder getOrder(int id) {
MyOrder dummy = (MyOrder)_messages.elementAt(id);
return dummy;
}
//...
private class ListCallback2 implements ListFieldCallback {
public Vector listElements = new Vector();
public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
String text = "dummy";
String text2 = (String)listElements.elementAt(index);
try {
MyOrder myDummy = new MyOrder();
myDummy = (MyOrder)getOrder(index); // <--------- error here
text2 = "OK";
} catch (Exception ex) {
System.out.println("Fehler:> "+ex);
}
text = _messages.size() + "|"+_messages.capacity()+"|"+index+"|"+text2;
g.drawText(text, 15, y, 0, w);
}
In the marked line i get a
ClassCastException - Error, but i dont know why...
I tried it with / without
(MyOrder) and with / without
new MyOrder()
so how do i get the Object from the index i want to?
tahnks hibbert