×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    214

    Post Please help me urgent

    Hi all


    Can anyone help me in making the code in the comment area work related to lwuit...............................

    The code is as follows

    public class CalForm extends Form implements ActionListener
    {
    private TextField display = new TextField("");
    protected MIDlet parentMidlet;
    private String buttonText = "C/*-+9876543210.=";
    private double result = 0;
    private String operator = "=";
    private boolean calculating = true;
    protected String operation = "+-/*";
    protected Button b;
    protected Command exit;
    protected Float res;
    protected String valone,valtwo;


    public CalForm(MIDlet parent)
    {
    super();
    parentMidlet = parent;
    init();
    }
    public void init()
    {
    getStyle().setBgColor(0x2f2f32);
    setLayout(new BorderLayout());
    exit = new Command("Exit");
    addCommand(exit);
    addCommandListener(this);
    display.setEditable(false);
    display.setSingleLineTextArea(true);
    display.setConstraint(TextField.UNEDITABLE);
    addComponent(BorderLayout.NORTH,display);
    Container p = new Container();
    p.setLayout(new GridLayout(4, 4));

    for (int i = 0; i < buttonText.length(); i++)
    {
    b = new Button(buttonText.substring(i, i + 1));
    b.getStyle().setBgColor(0x25f5644);
    p.addComponent(b);
    b.addActionListener(this);
    }
    addComponent(BorderLayout.CENTER,p);
    }

    public void actionPerformed(ActionEvent ae)
    {
    String Clear = ("C");

    if(ae.getSource() instanceof Command)
    {
    if(ae.getSource()== exit)
    {
    parentMidlet.notifyDestroyed();
    }
    }
    if(ae.getSource() instanceof Button)
    {
    Button btn = (Button) ae.getSource();

    if (buttonText.indexOf(btn.getText()) > -1)
    {
    display.setText(display.getText() + btn.getText());
    }
    if (Clear.indexOf(btn.getText()) > -1)
    {
    resetCalculator();
    }
    }

    // String cmd = (String) ae.getSource();
    //
    // if ('0' <= cmd.charAt(0) && cmd.charAt(0) <= '9' || cmd.equals("."))
    // {
    // if (calculating)
    // {
    // display.setText(cmd);
    // }
    // else
    // {
    // display.setText(display.getText() + cmd);
    // }
    // calculating = false;
    // }
    // else
    // {
    // if (calculating)
    // {
    // if (cmd.equals("-"))
    // {
    // display.setText(cmd);
    // calculating = false;
    // }
    // else
    // operator = cmd;
    // }
    // else
    // {
    // double x = Double.parseDouble(display.getText());
    // calculate(x);
    // operator = cmd;
    // calculating = true;
    // }
    // }
    // }
    // private void calculate(double n)
    // {
    // if (operator.equals("+"))
    // {
    // result += n;
    // }
    //
    // else if (operator.equals("-"))
    // {
    // result -= n;
    // }
    //
    // else if (operator.equals("*"))
    // {
    // result *= n;
    // }
    // else if (operator.equals("/"))
    // {
    // result /= n;
    // }
    // else if (operator.equals("="))
    // {
    // result = n;
    // }
    // display.setText("" + result);
    }

    private void resetCalculator()
    {
    display.setText("");
    }
    }

    Thank you

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Please help me urgent

    Well I would recommend you that please specify your requirement and it will not be good to read the code of your interest and then understand that what you need.

    So please specify the need and also ask the same thing on the LWUIT forums.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    214

    Re: Please help me urgent

    Quote Originally Posted by raj_J2ME View Post
    Well I would recommend you that please specify your requirement and it will not be good to read the code of your interest and then understand that what you need.

    So please specify the need and also ask the same thing on the LWUIT forums.

    Hi raj_J2ME thank you for the suggestion I have also posted the same thread in lwuit forum................... I want the code in the comment area to work in emulator so please can u help me in solving this......................................



    Thank you
    Last edited by kumarv75; 2010-08-12 at 06:47.

  4. #4
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Please help me urgent

    and what should that code do ? and what does it actually do ? so please state the problem ?
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    214

    Re: Please help me urgent

    Quote Originally Posted by Tiger79 View Post
    and what should that code do ? and what does it actually do ? so please state the problem ?
    Hi Tiger its a calculator program in lwuit so can u help me in solving it if the code in the comment is altered properly it would give a calculator o/p in emulator so can u help me in this problem ......................


    Thank you

Similar Threads

  1. Help me.......URGENT!!
    By medicha in forum Mobile Java General
    Replies: 0
    Last Post: 2006-03-17, 10:36
  2. PLEASE HELP ME THIS IS SO URGENT!!!
    By SIBUK in forum Symbian
    Replies: 3
    Last Post: 2006-02-28, 23:38
  3. 6630 and Http -- Nokia PLEASE HELP ME -- URGENT URGENT!!!!
    By earamsey in forum Mobile Java General
    Replies: 1
    Last Post: 2005-12-02, 17:06
  4. MORE URGENT THAN URGENT-need help with coding
    By jpcoffey in forum Browsing and Mark-ups
    Replies: 2
    Last Post: 2002-12-20, 15:13

Posting Permissions

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