2

私はこれをしばらく使用してきましたがJLabel、クリック イベントで 2 つの s のテキストを変更することはできません。

どんな助けでも大歓迎です。前もって感謝します。

これは、フィールドから入力を取得して計算を行う 2 つのラジオ ボタン グループを持つ GUI プログラムです。次に、計算を a に送信し、それにJLabel基づいて計算を行い、2 番目の に送信しますJLabel

コード:


public void jRB1ActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Length of Loan to 1 year:
    year = 1;
}

public void jRB2ActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Length of Loan to 2 years:
    year = 2;
}

public void jRB3ActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Length of Loan to 3 years:
    year = 3;
}

public void jRB4ActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Length of Loan to 4 years:
    year = 4;
}

public void jRB5ActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Length of Loan to 5 years:
    year = 5;
}

public void jRB6ActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Length of Loan to 6 years:
    year = 6;
}

public void jRB7ActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Intrest Rate to 5%:
    intrest = 5;
}

public void jRBActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Intrest Rate to 10%::
    intrest = 10;
}

public void jRB9ActionPerformed(java.awt.event.ActionEvent evt) {
    // Set the Intrest Rate to 12%:
    intrest = 12;
}

public void CalcActionPerformed(java.awt.event.ActionEvent evt) {
    // Button Click will get the value of the Loan from the jTFLoanAmmount
    // Performs the calculation RP = Loan Amount * (Interest Rate / 12) / [1-(1 + (Interest Rate / 12))^ - // (The length of Loan *12)]:
    //It will then send the result to the jLRPOut JLable
    //It will then send the result of the above calculation *(The length of Loan *12) to the //jLTotalLoanOut JLable
    double RP=(double)((Double.parseDouble(jTFLoanAmount.getText()))*(ir)/(1-1/Math.pow(1+ir, month)));
    jLRPOut.setText(String.valueOf(RP));
    double TLC=(double)((Float.parseFloat(jLRPOut.getText()))*(month));
    jLTotalLoanOut.setText(String.valueOf(TLC));
}


/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /*
     * Set the Nimbus look and feel
     */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /*
     * If Nimbus (introduced in Java SE 6) is not available, stay with the
     * default look and feel. For details see
     * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(AOOADJavaLoanCalculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(AOOADJavaLoanCalculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(AOOADJavaLoanCalculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(AOOADJavaLoanCalculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /*
     * Create and display the form
     */
    java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            new AOOADJavaLoanCalculator().setVisible(true);
        }
    });
}
// Variables declaration - do not modify                     
private javax.swing.JButton Calc;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.JLabel jL1;
private javax.swing.JLabel jL2;
private javax.swing.JLabel jL3;
private javax.swing.JLabel jLRPOut;
private javax.swing.JLabel jLTotalLoanOut;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JRadioButton jRB;
private javax.swing.JRadioButton jRB1;
private javax.swing.JRadioButton jRB2;
private javax.swing.JRadioButton jRB3;
private javax.swing.JRadioButton jRB4;
private javax.swing.JRadioButton jRB5;
private javax.swing.JRadioButton jRB6;
private javax.swing.JRadioButton jRB7;
private javax.swing.JRadioButton jRB9;
private javax.swing.JTextField jTFLoanAmount;
private javax.swing.JTabbedPane jTabbedPane1;
// End of variables declaration                   

// My Variables
public int year = 0;
public int month = year * 12;
public int intrest = 0;
public double ir = intrest / 12;

}
4

0 に答える 0