我创建了一个链接到JFrame工作表的项目,该项目显示面板,但是按钮不响应。我什至无法编辑某些编码,因为它是从IDE自动生成的代码。我在想的可能是缺少动作处理程序。
private void buttonCalculateActionPerformed(java.awt.event.ActionEvent evt) {
// declare variables;
float monthlyAmount;
float annualinterestRate;
float monthlyinterestRate;
float months;
float years;
float i;
float futureValue = 0;
String msg = "";
//input - read the boxes in FVForm design
monthlyAmount = Float.parseFloat(txtmonthlyAmount.getText());
annualinterestRate = Float.parseFloat(txtannualinterestRate.getText());
years = Float.parseFloat(txtyears.getText());
//process - obtain the monthly interest rate
months = 12 * years;
monthlyinterestRate = annualinterestRate/12/100;
list2.removeAll();
//output - Calculate the future values for each month
for (i = 1; i <= months; i++) {
futureValue = (futureValue + monthlyAmount) * (1 + monthlyinterestRate);
msg = String.format("Month: %3d Value: $%8.2f", i, futureValue);
list2.add(msg);
}// end for loop
}