ola pessoal como poderia …chamar essa classe dentro do meu botão ,
não sei aonde colocar to com essa duvida !!!
//botão
[code]private void btnConsistirActionPerformed(java.awt.event.ActionEvent evt) {
/* verifica se o campos esta vazio */
if (txtCodigo.getText().equals("")){
/*seta o background para vermelho */
txtBairro.setBackground(Color.RED);
txtCodigo.setBackground(Color.RED);
txtComplemento.setBackground(Color.RED);
txtCpf.setBackground(Color.RED);
txtDataNascimento.setBackground(Color.RED);
txtEndereco.setBackground(Color.RED);
txtNomesegurado.setBackground(Color.RED);
txtNumero.setBackground(Color.RED);
txtPremio.setBackground(Color.RED);
cmbProduto.setBackground(Color.RED);
cmbSexo.setBackground(Color.RED);
} else {
/*seta o background para branco */
txtBairro.setBackground(Color.WHITE);
txtCodigo.setBackground(Color.WHITE);
txtComplemento.setBackground(Color.WHITE);
txtCpf.setBackground(Color.WHITE);
txtDataNascimento.setBackground(Color.WHITE);
txtEndereco.setBackground(Color.WHITE);
txtNomesegurado.setBackground(Color.WHITE);
txtNumero.setBackground(Color.WHITE);
txtPremio.setBackground(Color.WHITE);
txtComplemento.setBackground(Color.WHITE);
cmbProduto.setBackground(Color.WHITE);
cmbSexo.setBackground(Color.WHITE);
}
String xCpf = txtCpf.getText();
if(!ValidaCPF.validaCpf(xCpf)){
new Mensagem(this,"Aviso", " CPF incorreto !!! ", Mensagem.MSG_BOTAO_OK, Mensagem.MSG_ICONE_INFORMACAO);
}
} [/code]
//classe data validar
[code]package util.Data;
import java.util.GregorianCalendar;
public class DataVerificar {
//public static void main(String[] s) {
// System.out.println(validaData("22/09/2010"));
// }
public static boolean validaData(String data) {
GregorianCalendar calendar = new GregorianCalendar();
int dia = 0,mes = 0,ano = 0;
String diaStr = data.substring(0,2);
String mesStr = data.substring(3,5);
String anoStr = data.substring(6,10);
try {
dia = Integer.parseInt(diaStr);
mes = Integer.parseInt(mesStr);
ano = Integer.parseInt(anoStr);
} catch (Exception e) {
return false;
}
if (dia < 1 || mes < 1 || ano < 1)
return false;
else
if (mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12)
if (dia <= 31)
return true;
else
return false;
else
if (mes == 4 || mes == 6 || mes == 9 || mes == 11)
if (dia <= 30)
return true;
else
return false;
else
if (mes == 2)
if (calendar.isLeapYear(ano))
if (dia <= 29)
return true;
else
return false;
else
if (dia <= 28)
return true;
else
return false;
else
if (mes > 12)
return false;
return true;
}
} [/code]