• Post Reply Bookmark Topic Watch Topic
  • New Topic

help adding values within a jtextfield  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies if this is an easy answer or has been answered, i am fairly new to coding. I have a supermarket checkout line where i have a list of available products on the left and then a basket on the right with the products in. The products are listed in an array, here is the product class



with getters and setters excluded, and the list these are put into



i have the price for each product to be displayed in a text field with the following code




defaultCheckoutList contains my available items and defaultMainList is the basket, with mainTillPrice being the jtextfield.
This works to get the price however it just replaces each time i make a new entry with the price for the next item, i want a total of the price of all the items i have added, but not sure how, any help would be appreciated as i am fairly stuck on this.
 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch. Thanks for using code tags.

Does this line really work? Is the selected value of mainCheckoutList really a Product?



I would think you need a line like this:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!