Hi all,
I have a list which when selected puts the selected value into a textfield. Now whenever i select from the list it gives "array index out of bounds" exception.
"java.lang.ArrayIndexOutOfBoundsException: 1 >= 0"
Please specify where am i wrong. In the calling function or when it is defined in "VKJItem".
This is what i am doing: when the button is pressed
**************************************************************
try
{
// Get the record ID of the currently selected contact
int itemindexorder = orderItemSearchDisplay.getSelectedIndex();
int iditemorder = ((Integer)itemIDs.elementAt(itemindexorder)).intValue();
// Retrieve the CLIENT record from the database
VKJItem vkjitemorder = dbitem.getItemRecord(iditemorder);
// Initialize the CLIENT fields
orderitemField.setString(vkjitemorder.getItemName());
orderrateField.setString(vkjitemorder.getItemRate());
//Set the current display to ITEM ENTRY SCREEN
display.setCurrent(orderScreenDisplay);
}
catch(Exception e)
{
System.err.println(e);
}
***************************************************************
Code of VKJItem is as follows: Its a separate class. Is there any problem in "unpack" below.
import java.util.*;
public class VKJItem {
private String varitem, varpack, varrate;
public VKJItem(String i, String p, String r)
{
varitem = i;
varpack = p;
varrate = r;
}
public VKJItem(byte[] data) {
unpack(new String(data));
}
public void unpack(String data) {
int start = 0, end = data.indexOf(';');
varitem = data.substring(start, end);
start = end + 1;
end = data.indexOf(';', start);
varpack = data.substring(start, end);
start = end + 1;
varrate = data.substring(start, data.length());
}
public String pack() {
return (varitem + ';' + varpack + ';' + varrate);
}
public String getItemName() {
return varitem;
}
public String getItemPack() {
return varpack;
}
public String getItemRate() {
return varrate;
}
}
/* End of code VKJItem.java
*
*/
***************************************************************