Results 1 to 3 of 3
  1. #1
    Ashleyx3 is offline Member
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Question Can't use Math operators with variables I saved in Textfields

    so i have this code where i want users to input and item name along with some numbers for each item(which i would like to preform some math operations on) I'm using Record store
    working using WTK22

    //UI Text Fields
    TextField searchField = new TextField ("Search By Item Name", "", 25, TextField.ANY);
    TextField userId = new TextField ("Item ID", "", 25, TextField.ANY);
    TextField customerId = new TextField ("Item", "", 25, TextField.ANY);
    TextField productName = new TextField ("CTM", "", 25,TextField.NUMERIC);
    TextField productName2 = new TextField ("CTR", "", 25,TextField.NUMERIC);
    TextField productName3 = new TextField ("CTC", "", 25,TextField.NUMERIC);
    TextField orderQty = new TextField ("Quantity", "", 5,TextField.NUMERIC);


    and later on I want to
    orderIdForm.append( productName2 - productName);
    and it tells me i can do that with textfield.. so i tried
    orderIdForm.append(Float.parse(productName2) - Float.parse(productName)) ;
    still no luck... please help and thank you for your time

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Can't use Math operators with variables I saved in Textfields

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default Re: Can't use Math operators with variables I saved in Textfields

    What are you trying to achieve?

    If it's subtracting the integer representation of those Strings then you need to do the parsing, though I would use Integer.parse().
    If that doesn't work then you have to give us the full exception, including the stack trace, showing where in your code the exception is thrown.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. where methods final variables are saved
    By killutch in forum New To Java
    Replies: 7
    Last Post: 10-24-2012, 06:28 PM
  2. TextFields not showing up
    By Army in forum New To Java
    Replies: 7
    Last Post: 06-20-2012, 07:36 PM
  3. textfields - cursor
    By newbie123 in forum AWT / Swing
    Replies: 6
    Last Post: 09-29-2011, 07:39 PM
  4. Replies: 3
    Last Post: 09-25-2011, 10:56 AM
  5. adding textfields
    By themanepalli in forum Java Applets
    Replies: 1
    Last Post: 12-28-2010, 04:56 AM

Tags for this Thread

Posting Permissions

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