Skip to main content

Application Error

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
neerajj50
Offline
Joined: 2010-12-05

Hi All,
I am wrk on project where i am using Lwuit i had added 3 commands on the Lwuit Form.I got one command at left side working fine and remaing 2 on right side with menu,but the time i click on menu its is giving me ApplicationError:java.lang.outofmemory error
1.I am using Theme [while i remove the theme its wrk fine].
2.My theme size is 2kb.
3.This is Code:
public class MenuItems extends Form {

Button btn_admin, btn_transaction, btn_mines, btn_sodddo, btn_vagus_complex;
Form form;
private Image image;
Command info;
Command exit;
Container c;
Command count;
Label lbl_hhrid, lbl_space;

;
Container container;
boolean exit_flag = true;

public MenuItems(String title) {

super(title);
initialisaton();
addComponent();
}

public Label newLabel() {
Label spaceLabel = new Label(" ");
spaceLabel.setAlignment(Component.CENTER);
spaceLabel.getUnselectedStyle().setBgTransparency(0);
return spaceLabel;
}

public void initialisaton() {
setLayout(new BoxLayout(BoxLayout.Y_AXIS));
this.setMenuCellRenderer(new DefaultListCellRenderer(false));
container = new Container(new GridLayout(2, 2));
//setLayout(new GridLayout(1, 1));
lbl_space = new Label(" ");
lbl_hhrid = new Label(" HHR ID :" + ApplicationMidlet.hhr_id);
lbl_hhrid.getUnselectedStyle().setFgColor(13047173);
try {
btn_admin = new Button(Image.createImage("/admin.png"));
btn_mines = new Button(Image.createImage("/operations.png"));
btn_vagus_complex = new Button(Image.createImage("/operations.png"));
} catch (IOException ex) {
ex.printStackTrace();
}
//btn_admin.setTextPosition(Component.RIGHT);

//btn_mines.setTextPosition(Component.RIGHT);
btn_vagus_complex.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
ApplicationMidlet.vagusComplexForm.show();
}
});
btn_mines.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

if (ApplicationMidlet.midlet.access_to_sigao) {
ApplicationMidlet.loadParameterOREForm.getLongRouteCodes();
ApplicationMidlet.loadParameterOREForm.getProductCodes();
ApplicationMidlet.loadParameterOREForm.getSourceLocation();
ApplicationMidlet.loadParameterOREForm.getSourceSubLocation();
ApplicationMidlet.loadParameterOREForm.getDestinationLocation();
ApplicationMidlet.loadParameterOREForm.getBillingCategory();
ApplicationMidlet.loadParameterOREForm.getMachineCodes();

ApplicationMidlet.loadParameterREJForm.getShortRouteCodes();
ApplicationMidlet.loadParameterREJForm.getProductCodes();
ApplicationMidlet.loadParameterREJForm.getSourceLocation();
ApplicationMidlet.loadParameterREJForm.getSourceSubLocation();
ApplicationMidlet.loadParameterREJForm.getDestinationLocation();
ApplicationMidlet.loadParameterREJForm.getBillingCategory();
ApplicationMidlet.loadParameterREJForm.getMachineCodes();

ApplicationMidlet.uf.getDestinationLocation();
ApplicationMidlet.uf.getDestinationSublocation();

}

//ApplicationMidlet.forcefullyClosedForm.getDestinationLocation();
// ApplicationMidlet.forcefullyClosedForm.getDestinationSublocation();

ApplicationMidlet.TransactionsForm.show();
}
});

btn_sodddo = new Button("Soddo", image);
btn_sodddo.setTextPosition(Component.RIGHT);
// btn_vagus_complex= new Button("Vagus Complex",image);
// btn_vagus_complex.setTextPosition(Component.RIGHT);
btn_admin.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

ApplicationMidlet.admin.show();
//String s=ApplicationMidlet.midlet.getCheckSum("abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789cfgvbh1254kl");
// for(int i=0;i<256;i++)
// {
// int s=i;
// Dialog.show("INFO","char is : "+(char)s+"\n"+"ASCII : "+s,"Ok","Cancel");
// Dialog.show("INFO", ApplicationMidlet.midlet.displayHexString(""+(char)s),"Ok", "Cancel");
// }
}
});
try{
exit = new Command("Exit") {

public void actionPerformed(ActionEvent ev) {
RecordStore rs = null;
try {
rs = RecordStore.openRecordStore("VMSBOfflineRecordMemory", false);
int records = rs.getNumRecords();
rs.closeRecordStore();
exit_flag = Dialog.show("INFO", "Number of transactions : " + records, "Ok", "Cancel");
exitApp(exit_flag);
} catch (RecordStoreException ex) {
exit_flag = Dialog.show("INFO", "No records present !", "Ok", "Cancel");
exitApp(exit_flag);
} finally {
try {
rs.closeRecordStore();
} catch (RecordStoreNotOpenException ex) {
ex.printStackTrace();
} catch (RecordStoreException ex) {
ex.printStackTrace();
}
}

}
};
}catch(OutOfMemoryError oe)
{
System.out.println("Exception1 :"+oe.toString());
}
try{
info = new Command("Info") {

public void actionPerformed(ActionEvent ev) {
Dialog.show("INFO", "VMSB", "OK", "Cancel");
//ApplicationMidlet.midlet.errorTone();
}
};
}catch(OutOfMemoryError oe)
{
System.out.println("Exception 2:"+oe.toString());
}

try {

count = new Command("Get Count") {

public void actionPerformed(ActionEvent ae) {
System.out.println("Inside Count menu0 ");
displayCount();
}
};
} catch (OutOfMemoryError oe) {
System.out.println("Exception 3:" + oe.toString());
}

}

public void addComponent() {
addComponent(lbl_hhrid);
addComponent(lbl_space);
container.addComponent(btn_admin);
container.addComponent(btn_mines);
container.addComponent(btn_vagus_complex);
addComponent(container);
// addComponent(btn_admin);
// addComponent(btn_mines);
try{
addCommand(exit);
addCommand(count);
addCommand(info);
}catch(OutOfMemoryError oe)
{
System.out.println("Exception :"+oe.toString());
}

}

private void exitApp(boolean end_flag) {
if (end_flag) {
ApplicationMidlet.midlet.destroyApp(true);
ApplicationMidlet.midlet.notifyDestroyed();
}

}

private void displayCount() {
System.out.println("Inside Count menu ");
String info1 = "";
try {
ApplicationMidlet.midlet.routineDate();
String rs_name = ApplicationMidlet.midlet.myDate.substring(0, 8);
RecordStore rs_ = RecordStore.openRecordStore(rs_name, false);
RecordEnumeration re = rs_.enumerateRecords(null, null, false);
if (re.numRecords() > 0) {
while (re.hasNextElement()) {
byte[] bt = re.nextRecord();
String name = new String(bt);

try {
RecordStore rs1 = RecordStore.openRecordStore(name, false);
RecordEnumeration re1 = rs1.enumerateRecords(null, null, false);
while (re1.hasNextElement()) {
byte[] bt1 = re1.nextRecord();
String count1 = new String(bt1);
int c1 = Integer.parseInt(count1.substring(0, 4));
int c2 = Integer.parseInt(count1.substring(4, 8));
int c3 = Integer.parseInt(count1.substring(8, 12));
info1 = info1 + "\n" + name + "\n" + "ROM :" + c1 + "\n" + "REJ :" + c2 + "\n" + "P.ORE :" + c3;
}
rs1.closeRecordStore();
} catch (Exception ex1) {
}
}
rs_.closeRecordStore();
if (info1.trim().length() > 0) {
Dialog.show("INFO", info1, "Ok", "Cancel");
} else {
Dialog.show("INFO", "0 records !", "Ok", "Cancel");
}

}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

Please provide a concise example.