×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    3

    please help in solving the errors in a j2me program

    i am trying to study this program for better understanding of j2me. It is a simple notepad program but it has few errors. i got these errors after adding this program in NetBeans.
    can you please help me in solving them. The error statements are marked with /*/
    The program is as follows :

    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.io.InputStream;
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.AlertType;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.List;
    import javax.microedition.lcdui.TextBox;
    import javax.microedition.lcdui.TextField;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.rms.RecordEnumeration;
    import javax.microedition.rms.RecordStore;

    public class MiniNotepad extends MIDlet
    implements CommandListener
    {
    private Command a = new Command("New", 8, 1);
    private Command b = new Command("Open", 8, 2);
    private Command c = new Command("Save", 8, 3);
    private Command d = new Command("Delete", 8, 4);
    private Command e = new Command("Close", 8, 5);
    private Command f = new Command("Exit", 7, 6);
    private Command g = new Command("Ok", 8, 7);
    private Command h = new Command("About", 8, 8);
    private Command i = new Command("Insert line feed", 8, 4);
    private Form j;
    private List k;
    private TextBox l;
    private TextField m;
    private Alert n;
    private Alert o;
    private Alert p;
    private Display q;
    private RecordStore r = null;
    private String s;
    private String t;
    private int u;
    private boolean v = false;
    private ByteArrayOutputStream w = new ByteArrayOutputStream();
    private DataOutputStream x = new DataOutputStream(this.w);

    public void pauseApp()
    {
    if (this.r != null)
    b();
    }

    public void destroyApp(boolean paramBoolean)
    {
    if (this.r != null)
    b();
    }

    public void startApp()
    {
    if (this.q == null)
    {
    this.q = Display.getDisplay(this);
    this.j = new Form("Mini Notepad");
    this.k = new List("Mini Notepad", 3);
    this.l = new TextBox("Mini Notepad", null, 1024, 0);
    this.m = new TextField("File Name:", null, 32, 0);
    this.n = new Alert("Mini Notepad", "mininotepad@gmail.com v2.0 (2008)", null, AlertType.INFO);
    this.n.setTimeout(5000);
    this.o = new Alert("Mini Notepad", "Invalid file name", null, AlertType.INFO);
    this.o.setTimeout(2500);
    this.p = new Alert("Mini Notepad", "File Saved..", null, AlertType.INFO);
    this.p.setTimeout(2500);
    this.j.append(this.m);
    c();
    Display.getDisplay(this).setCurrent(this.k);
    this.l.addCommand(this.c);
    this.l.addCommand(this.e);
    this.l.addCommand(this.i);
    this.k.addCommand(this.f);
    this.k.addCommand(this.a);
    this.k.addCommand(this.b);
    this.k.addCommand(this.d);
    this.k.addCommand(this.h);
    this.j.addCommand(this.g);
    this.l.setCommandListener(this);
    this.k.setCommandListener(this);
    this.j.setCommandListener(this);
    }
    }

    public void commandAction(Command paramCommand, Displayable paramDisplayable)
    {
    if (paramCommand == this.f)
    {
    destroyApp(false);
    notifyDestroyed();
    }
    if (paramCommand == this.a)
    {
    Display.getDisplay(this).setCurrent(this.l);
    this.l.setString(null);
    this.v = true;
    }
    Last edited by pranali91; 2012-06-07 at 17:02.

  2. #2
    Registered User
    Join Date
    Jun 2012
    Posts
    3

    Re: please help in solving the errors in a j2me program

    2nd part of code

    MiniNotepad localMiniNotepad;
    Object localObject;
    /*/ if ((((paramCommand == this.b ? 1 : 0) | (paramCommand == List.SELECT_COMMAND ? 1 : 0)) != 0) && ((paramDisplayable = this.k.getSelectedIndex()) != -1))
    {
    Displayable localDisplayable = paramDisplayable;
    localMiniNotepad = this;
    /*/ paramDisplayable = 0;
    try
    {
    localMiniNotepad.a();
    if (localMiniNotepad.r.getNumRecords() > 0)
    {
    localObject = localMiniNotepad.r.enumerateRecords(null, null, false);
    while (((RecordEnumeration)localObject).hasNextElement())
    {
    int i2 = ((RecordEnumeration)localObject).nextRecordId();
    if (paramDisplayable == localDisplayable)
    {
    /*/ paramDisplayable = new byte[localMiniNotepad.r.getRecordSize(i2)];
    /*/ localMiniNotepad.r.getRecord(i2, paramDisplayable, 0);
    /*/ paramDisplayable = new ByteArrayInputStream(paramDisplayable);
    /*/ paramDisplayable = new DataInputStream(paramDisplayable);
    /*/ localMiniNotepad.s = paramDisplayable.readUTF();
    /*/ localMiniNotepad.t = paramDisplayable.readUTF();
    /*/ paramDisplayable.reset();
    localMiniNotepad.l.setString(localMiniNotepad.t);
    localMiniNotepad.u = i2;
    break;
    }
    /*/ paramDisplayable++;
    }
    }
    localMiniNotepad.b();
    }
    catch (Exception localException1)
    {
    }
    Display.getDisplay(this).setCurrent(this.l);
    this.v = false;
    }
    int i1;
    if (paramCommand == this.c)
    {
    if (this.v == true)
    {
    Display.getDisplay(this).setCurrent(this.j);
    return;
    }
    localObject = this.l.getString();
    /*/ paramDisplayable = this.s;
    i1 = this.u;
    localMiniNotepad = this;
    try
    {
    localMiniNotepad.a();
    /*/ localMiniNotepad.x.writeUTF(paramDisplayable);
    localMiniNotepad.x.writeUTF((String)localObject);
    localMiniNotepad.x.flush();
    localMiniNotepad.w.size();
    byte[] arrayOfByte = null;
    arrayOfByte = localMiniNotepad.w.toByteArray();
    localMiniNotepad.r.setRecord(i1, arrayOfByte, 0, arrayOfByte.length);
    localMiniNotepad.w.reset();
    localMiniNotepad.d();
    localMiniNotepad.c();
    localMiniNotepad.b();
    }
    catch (Exception localException2)
    {
    }
    Display.getDisplay(this).setCurrent(this.p);
    }
    /*/ if ((paramCommand == this.d) && ((paramDisplayable = this.k.getSelectedIndex()) != -1))
    {
    /*/ i1 = a(paramDisplayable);
    localMiniNotepad = this;
    try
    {
    localMiniNotepad.a();
    localMiniNotepad.r.deleteRecord(i1);
    localMiniNotepad.b();
    }
    catch (Exception localException3)
    {
    }
    /*/ this.k.delete(paramDisplayable);
    this.v = false;
    }
    if (paramCommand == this.e)
    {
    Display.getDisplay(this).setCurrent(this.k);
    this.v = false;
    }
    if (paramCommand == this.g)
    {
    if (this.m.size() == 0)
    {
    Display.getDisplay(this).setCurrent(this.o);
    return;
    }
    /*/ paramDisplayable = this.l.getString();
    this.s = this.m.getString();
    paramDisplayable = paramDisplayable;
    String str = this.s;
    localMiniNotepad = this;
    try
    {
    localMiniNotepad.a();
    localMiniNotepad.x.writeUTF(str);
    /*/ localMiniNotepad.x.writeUTF(paramDisplayable);
    localMiniNotepad.x.flush();
    localMiniNotepad.w.size();
    localObject = null;
    localObject = localMiniNotepad.w.toByteArray();
    /*/ localMiniNotepad.r.addRecord(localObject, 0, localObject.length);
    localMiniNotepad.w.reset();
    localMiniNotepad.b();
    }
    catch (Exception localException4)
    {
    }
    d();
    c();
    Display.getDisplay(this).setCurrent(this.k);
    this.m.setString(null);
    this.v = false;
    }
    if (paramCommand == this.h)
    Display.getDisplay(this).setCurrent(this.n);
    if (paramCommand == this.i)
    this.l.insert("\r\n", this.l.getCaretPosition());
    }
    Last edited by pranali91; 2012-06-07 at 17:05.

  3. #3
    Registered User
    Join Date
    Jun 2012
    Posts
    3

    Re: please help in solving the errors in a j2me program

    private void a()
    {
    try
    {
    this.r = RecordStore.openRecordStore("MiniNotepadDB", true);
    return;
    }
    catch (Exception localException)
    {
    }
    }

    private void b()
    {
    try
    {
    this.r.closeRecordStore();
    return;
    }
    catch (Exception localException)
    {
    }
    }
    private void c()
    {
    try
    {
    a();
    if (this.r.getNumRecords() > 0)
    {
    RecordEnumeration localRecordEnumeration = this.r.enumerateRecords(null, null, false);
    while (localRecordEnumeration.hasNextElement())
    {
    int i1 = localRecordEnumeration.nextRecordId();
    byte[] arrayOfByte = new byte[this.r.getRecordSize(i1)];
    this.r.getRecord(i1, arrayOfByte, 0);
    Object localObject = new ByteArrayInputStream(arrayOfByte);
    localObject = new DataInputStream((InputStream)localObject);
    this.s = ((DataInputStream)localObject).readUTF();
    ((DataInputStream)localObject).reset();
    this.k.append(this.s, null);
    }
    }
    b();
    return;
    }
    catch (Exception localException)
    {
    }
    }

    private int a(int paramInt)
    {
    int i1 = 0;
    int i2 = 0;
    try
    {
    a();
    if (this.r.getNumRecords() > 0)
    {
    RecordEnumeration localRecordEnumeration = this.r.enumerateRecords(null, null, false);
    while (localRecordEnumeration.hasNextElement())
    {
    int i3 = localRecordEnumeration.nextRecordId();
    if (i1 == paramInt)
    {
    i2 = i3;
    break;
    }
    i1++;
    }
    }
    b();
    }
    catch (Exception localException)
    {
    }
    return i2;
    }

    private void d()
    {
    try
    {
    int i1 = this.k.size();
    int i2 = 0;
    if (i1 > 0)
    while (i2 < i1)
    {
    this.k.delete(0);
    i2++;
    }
    return;
    }
    catch (Exception localException)
    {
    }
    }
    }


    this is the 3rd part of the code.

Similar Threads

  1. Replies: 11
    Last Post: 2010-08-21, 12:11
  2. Replies: 1
    Last Post: 2002-07-10, 12:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •