calculations

On my GUI i have 20 buttons which each represent a product and a price when they are selected the prices are added together and displayed in a JTextField. I also have number buttons 1-9 and I need to choose a quantity when selecting each product. How can i get the quantity i choose to multiply it by the button value and add it to the total?

example i choose: 3 bottles of water, each bottle costs ?, when i select 3 and the bottle of water i need it to add ? onto the total how do i do this?

[506 byte] By [lozengera] at [2007-11-26 19:58:55]
# 1
You can do that by event handlers on your button's click event. Thanks,Rashmi
rashmigopinatha at 2007-7-9 22:55:11 > top of Java-index,Java Essentials,Java Programming...
# 2

I would suggest that you rethink this layout. Using buttons in this way is not particularly intuitive IMO ...

I think what might be a better layout would be to use a text-field for quantity, labels for item and price and one button like "GO" to kick off the calculations. Anyway ... something like this.

abillconsla at 2007-7-9 22:55:11 > top of Java-index,Java Essentials,Java Programming...