0
private void btCalcularActionPerformed(java.awt.event.ActionEvent evt) {
double salario = 0, irrf = 0, inss = 0, valorTotal = 0;
FolhaPagamento pagamento = new FolhaPagamento(Double.parseDouble(txtValorSalario.getText()));
salario = pagamento.getSalario();
if(cbIRRF.isSelected()){
irrf = salario * 0.17;
txtIRRF.setText(String.valueOf(irrf));
}
else txtIRRF.setText("");
if(cbINSS.isSelected()){
inss = salario * 0.05;
txtINSS.setText(String.valueOf(inss));
}
else txtINSS.setText("");
valorTotal = salario + irrf + inss;
txtValorTotal.setText(String.valueOf(valorTotal));
}
The user enters any numerical value related to the employee’s salary and can click on the checkboxes (JCheckBox
) relating to incidental contributions. If the IRRF box is checked, the value of the Withheld Income Tax should appear in the corresponding Source, that is, 17% of the salary value. Similarly, if the INSS box is checked, the corresponding INSS value should appear (5%).
You can add the code of what you tried to ask in the question?
– user28595
@Articuno pus
– José Guilherme
But your question is how to capture the selection event on
JCheckBox
in order to do something ?– Isac