how can I show multiple lines on gui textField, right now it will only show the latest "value". Please click on the link below to see the GUI output. Notice it's only showing the 2 $1.
https://drive.google.com/file/d/0B2-...it?usp=sharing
GUI Code
private void paymentTextFieldActionPerformed(java.awt.event.ActionEvent evt) { double payment = Double.parseDouble(paymentTextField.getText()); paymentTextField.setText(fmt.format(payment)); finalChange = payment - allTotal; change.setText(String.valueOf(fmt.format(finalChange))); int dollar; double cent; dollar = (int)finalChange % 1000000; cent = finalChange - dollar; if((dollar / 100) >= 1) { changeTextArea.setText(dollar / 100 + " $100"); dollar = dollar - 100 * (dollar / 100); } if((dollar / 50) >= 1) { changeTextArea.setText(dollar / 50 + " $50"); dollar = dollar - 50 * (dollar / 50); } if((dollar / 20) >= 1) { changeTextArea.setText(dollar / 20 + " $20"); dollar = dollar - 20 * (dollar / 20); } if((dollar / 10) >= 1) { changeTextArea.setText(dollar / 10 + " $10"); dollar = dollar - 10 * (dollar / 10); } if((dollar / 5) >= 1) { changeTextArea.setText(dollar / 5 + " $5"); dollar = dollar - 5 * (dollar / 5); } if((dollar / 1) >= 1) { changeTextArea.setText(dollar / 1 + " $1"); } }
test code output, what I want the GUI above to look like
1 $5 2 $1 3 $0.01
test code
package correctchange; public class CorrectChange { public static void main(String[] args) { double change = 7.03; int dollar; double cent; dollar = (int)change % 1000000; cent = change - dollar; // dollar calculation if((dollar / 100) >= 1) { System.out.println(dollar / 100 + " $100"); dollar = dollar - 100 * (dollar / 100); } if((dollar / 50) >= 1) { System.out.println(dollar / 50 + " $50"); dollar = dollar - 50 * (dollar / 50); } if((dollar / 20) >= 1) { System.out.println(dollar / 20 + " $20"); dollar = dollar - 20 * (dollar / 20); } if((dollar / 10) >= 1) { System.out.println(dollar / 10 + " $10"); dollar = dollar - 10 * (dollar / 10); } if((dollar / 5) >= 1) { System.out.println(dollar / 5 + " $5"); dollar = dollar - 5 * (dollar / 5); } if((dollar / 1) >= 1) { System.out.println(dollar / 1 + " $1"); } // cents calculation if((cent / 0.25) >= 1.00) { System.out.println((int)(cent / 0.25) + " $0.25"); cent = cent - 0.25 * (cent / 0.25); } if((cent / 0.10) >= 1.00) { System.out.println((int)(cent / 0.10) + " $0.10"); cent = cent - 0.10 * (cent / 0.10); } if((cent / 0.05) >= 1.00) { System.out.println((int)(cent / 0.05) + " $0.05"); cent = cent - 0.05 * (cent / 0.05); } if((cent / 0.01) >= 1.00) { System.out.println((int)(cent / 0.01) + " $0.01"); // cent = cent - 0.01 * (cent / 0.01); } } }