Results 1 to 12 of 12

Thread: Java Question

  1. #1
    Jay-1.1 is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default Java Question

    I want to display a text field that shows the cost of a selected item or items how would I go about this?

    In my code I have two text areas one with all the items and prices in and a blank text area. When I input a value into a text field it puts the selected item from the first text area into the second text area.

    Any help would be appreciated.

    Thanks

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Selected item? or matched item?

    Just cut those matched item,
    - have a copy of the content
    - Remove that matched item
    - Show the new content.

    store in a temp variable,
    - A String variable

    append it to the 2nd textArea.

    If you can post the content of your first textArea,
    Much better......
    freedom exists in the world of ideas

  3. #3
    Jay-1.1 is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    When I enter a item number into a text field it brings up the item in the second text area.

    private void makeItem() {
    games[numberOfItems] = new Item("Ball", 39.99f);
    numberOfItems++;
    }

    This is how I created the items I now want to get the 39.99f price out and put it into a separate text field. Also when I add more items I want it to add that to the total.

    Thanks
    Last edited by Jay-1.1; 05-01-2008 at 03:49 PM.

  4. #4
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Content, not code.....

    (the text which appeared from your 1st textArea.)
    freedom exists in the world of ideas

  5. #5
    Jay-1.1 is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default All my code

    Deleted code
    Last edited by Jay-1.1; 05-01-2008 at 04:15 PM.

  6. #6
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    I guess the content of your textArea is like:

    Grand Theft Auto IV
    39.99f

    FIFA 2008
    37.99f

    Assassins Creed
    39.99f

    Formula One Chapionship Edition
    25.00f

    Pro Evolution Soccer 2008
    24.99f

    Euro 2008
    39.99f

    Football Manager 2008
    19.99f
    am i right?
    freedom exists in the world of ideas

  7. #7
    Jay-1.1 is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    I still dont get how to do a cost field my code already works like i want it to and was complete until i wanted to include a cost field. I just want to display the cost of the selected items in a cost field
    Last edited by Jay-1.1; 05-01-2008 at 04:26 PM.

  8. #8
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    I doubt now....

    @ first post, you're saying like
    "transfer the matched text(based on textfield) from textArea1 to textArea2"

    And now, you're just gonna display it? how?
    I really don't understand you're problem.....

    I just want to display the cost of the selected items in a cost field
    What is that cost field? textArea? List? or textfield?

    You should be specific bro....

    Im asking you if i am right at post #6.
    Or, post that content like what i've guess @ #6
    freedom exists in the world of ideas

  9. #9
    Jay-1.1 is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    Yes the content of text area 1 is like that just without the f sorry didnt see that. Then when i select it, it copies the item from text area 1(Games) and puts it into text area 2 (games selected) and thats the one that i need to get the cost out of. To display in a NEW Cost text field that shows the cost which i have already created.

    Thanks
    Last edited by Jay-1.1; 05-01-2008 at 04:49 PM.

  10. #10
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Then when i select it
    How did you select it? By highlighting it? or how?

    After choosing that value for textArea1, what component did you use to trigger the value transfer?
    freedom exists in the world of ideas

  11. #11
    Jay-1.1 is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    I entered the number of the game and selected the submit game button that transfers it from games to selected games.

    0.Grand Theft Auto IV (39.99)
    1.Euro 2008 (39.99)

  12. #12
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Java Code:
    games[numberOfGames] = new Game("Grand Theft Auto IV", 39.99f);
    numberOfGames++;
    Base on the code you've posted,

    It would be nice if you add those values on an array
    Example:
    gamename[x]
    cost[x]....

    eg: gamename[x] = name_of_the_game;
    cost[x] = name_of_the_game_COST;

    When you input a number, it should represents the gamename and cost right?

    Try to access that cost[x] array to get the value...
    And append to the second textArea.
    freedom exists in the world of ideas

Similar Threads

  1. Java Question, i need to be answered
    By Sunshine in forum New To Java
    Replies: 7
    Last Post: 04-28-2008, 02:00 PM
  2. Quick Java question/help
    By Zedy in forum New To Java
    Replies: 6
    Last Post: 04-22-2008, 04:40 AM
  3. A core java Question
    By chravikumar008 in forum New To Java
    Replies: 2
    Last Post: 04-21-2008, 09:04 AM
  4. New Comer, Java C# question
    By lmei007 in forum Advanced Java
    Replies: 0
    Last Post: 02-04-2008, 05:54 PM
  5. Java Review Question
    By toad in forum New To Java
    Replies: 1
    Last Post: 10-29-2007, 07:13 AM

Posting Permissions

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