Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding new button to gui calculator

 
mike saggese
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, this might be a oddball question but how do I add total payment to this gui calculator? I know the code works for sure, and somewhere in the code there's

//Labels to identify the fields
private JLabel amountLabel;
private JLabel rateLabel;
private JLabel numPeriodsLabel;
private JLabel paymentLabel;

//Strings for the labels
private static String amountString = "Loan Amount: ";
private static String rateString = "Interest Rate (%): ";
private static String numPeriodsString = "Years: ";
private static String paymentString = "Monthly Payment: ";

//Fields for data entry
private JFormattedTextField amountField;
private JFormattedTextField rateField;
private JFormattedTextField numPeriodsField;
private JFormattedTextField paymentField;

//Formats to format and parse numbers
private NumberFormat amountFormat;
private NumberFormat percentFormat;
private NumberFormat paymentFormat;

can I just simply add total payment to the JFormatted TextField and paymentString or is there something else I need to do?

 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mike saggese wrote:Hi, this might be a oddball question but how do I add total payment to this gui calculator? I know the code works for sure, and somewhere in the code there's

can I just simply add total payment to the JFormatted TextField and paymentString or is there something else I need to do?

What happened when you tried it?
 
mike saggese
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:
mike saggese wrote:Hi, this might be a oddball question but how do I add total payment to this gui calculator? I know the code works for sure, and somewhere in the code there's

can I just simply add total payment to the JFormatted TextField and paymentString or is there something else I need to do?

What happened when you tried it?


I know that without the button all I have to do is hit enter and it automatically calculates the payment. but what if I add the button to the code, where should I add it so it won't mess up the entire thing.

Another question I have is how do I make this java file also a web page html file?
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
again, I'll ask "What have you tried?"

Folks here don't hand out solutions to problems. We try to teach and guide. We expect you to ShowSomeEffort (that's a link to a page you should probably read). In fact, you may want to read much of this to get the most out of our site.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic