Bueno aqui les dejo un programa que hise para que te dieran el RFC poniendo tus datos:
Primero debes abrir una hoja con el titulo Persona por ejemplo y pones este codigo:
class Persona {
public String nombre;
private String apePat;
private String apeMat;
private int añoNac;
private int mesNac;
private int diaNac;
private int diaAct;
private int mesAct;
private int añoAct;
private int edad;
private String rfc;
public void setNombre(String nombre){
this.nombre=nombre;
}
public String getNombre(){
return nombre;
}
public void setApePat ( String apePat){
this.apePat=apePat;
}
public String getApePat (){
return apePat;
}
public void setApeMat(String apeMat){
this.apeMat=apeMat;
}
public String getApeMat (){
return apeMat;
}
public void setDiaNac (int diaNac){
this.diaNac=diaNac;
}
public int getDiaNac(){
return diaNac;
}
public void setMesNac(int mesNac){
this.mesNac=mesNac;
}
public int getMesNac(){
return mesNac;
}
public void setAñoNac(int añoNac){
this.añoNac=añoNac;
}
public int getAñoNac(){
return añoNac;
}
public void setDiaAct(int diaAct){
this.diaAct=diaAct;
}
public int getDiaAct(){
return diaAct;
}
public void setMesAct(int mesAct){
this.mesAct=mesAct;
}
public int getMesAct(){
return mesAct;
}
public void setAñoAct(int añoAct){
this.añoAct=añoAct;
}
public int getAñoAct(){
Luego abres otra hoja la cual le pondras de nombre MainPersona y le pones este codigo:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.String.*;
public class MainPersona extends JFrame{
int cont=0;
String edadC;
Persona []p=new Persona[5];
JPanel panel0=new JPanel(new GridLayout(2,1)) ;
JPanel panel1=new JPanel(new GridLayout(11,2)) ;
JPanel panel2=new JPanel(new GridLayout(1,5)) ;
JLabel label1=new JLabel("Teclea tu Nombre: " ) ;
JLabel label2=new JLabel("Teclea tu Apellido Paterno: " ) ;
JLabel label3=new JLabel("Teclea tu Apellido Materno: " ) ;
JLabel label4=new JLabel("Dia de nacimiento (dos digitos) : " ) ;
JLabel label5=new JLabel("Mes de nacimiento (dos digitos) : " ) ;
JLabel label6=new JLabel("Año de nacimiento (cuatro digitos) : " ) ;
JLabel label7=new JLabel("El dia de hoy(dos digitos: ) " ) ;
JLabel label8=new JLabel("El mes en el que estamos(dos digistos) : " ) ;
JLabel label9=new JLabel("El año en el que te encuentras(cuatro digitos) : " ) ;
JLabel label10=new JLabel("Esta es tu edad : " ) ;
JLabel label11=new JLabel("Este es tu RFC : " ) ;
JTextField text1=new JTextField() ;
JTextField text2=new JTextField() ;
JTextField text3=new JTextField() ;
JTextField text4=new JTextField() ;
JTextField text5=new JTextField() ;
JTextField text6=new JTextField() ;
JTextField text7=new JTextField() ;
JTextField text8=new JTextField() ;
JTextField text9=new JTextField() ;
JTextField text10=new JTextField() ;
JTextField text11=new JTextField() ;
JButton butE= new JButton("Cal edad" ) ;
JButton butC= new JButton("Cal RFC" ) ;
JButton butG= new JButton("Guardar" ) ;
JButton butL= new JButton("Limpiar" ) ;
JButton butR= new JButton("Reporte" ) ;
JButton butS= new JButton("Salir" ) ;
public MainPersona(){
super ("Datos Personales" ) ;
this.setSize(500,700 ) ;
this.setResizable(false) ;
this.setVisible(true) ;
this.setDefaultCloseOperation(EXIT_ON_CLOSE) ;
getContentPane().add(panel0) ;
panel0.setBorder(BorderFactory.createEmptyBorder(2,2,2,2 ) ) ;
panel0.add(panel1) ;
panel0.add(panel2) ;
panel1.add(label1) ;
panel1.add(text1) ;
panel1.add(label2) ;
panel1.add(text2) ;
panel1.add(label3) ;
panel1.add(text3) ;
panel1.add(label4) ;
panel1.add(text4) ;
panel1.add(label5) ;
panel1.add(text5) ;
panel1.add(label6) ;
panel1.add(text6) ;
panel1.add(label7) ;
panel1.add(text7) ;
panel1.add(label8) ;
panel1.add(text8) ;
panel1.add(label9) ;
panel1.add(text9) ;
panel1.add(label10) ;
panel1.add(text10) ;
panel1.add(label11) ;
panel1.add(text11) ;
text10.setEditable(true) ;
text11.setEditable(true) ;
panel2.add(butG) ;
panel2.add(butE) ;
panel2.add(butC) ;
panel2.add(butL) ;
panel2.add(butR) ;
panel2.add(butS) ;
butE.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
for(int i=0; i<cont; i++){
text10.setText(p.calcEdad()+ "" );
/*p.setDiaNac(Integer.parseInt(text4.getText( ) ) ) ;
p.setMesNac(Integer.parseInt(text5.getText( ) ) ) ;
p.setAñoNac(Integer.parseInt(text6.getText( ) ) ) ;
p.setDiaAct(Integer.parseInt(text7.getText( ) ) ) ;
p.setMesAct(Integer.parseInt(text8.getText( ) ) ) ;
p.setAñoAct(Integer.parseInt(text9.getText( ) ) ) ;
//edad=p[0].calcEdad() ;
// String edadC=edad+"" ;
text11.setText(p.calcEdad()+"" ) ;
text10.setText(edadC) ;
//text11.setText(edadC) ; * /
}
}
});
butC.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String N="" ;
String P="" ;
String Ma="" ;
String D="" ;
String M="" ;
String A="" ;
String rfc= "" ;
N=new String (text1.getText() ) ;
P=new String (text2.getText() ) ;
Ma=new String (text3.getText() ) ;
D=new String (text4.getText() ) ;
M=new String (text5.getText() ) ;
A=new String (text6.getText() ) ;
N=N.substring(0,1) ;
System.out.println("N: "+N) ;
P=P.substring(0,2) ;
System.out.println("P: "+P) ;
Ma=Ma.substring(0,1) ;
System.out.println("Ma: "+Ma) ;
D=D.substring(0,2) ;
System.out.println("D: "+D) ;
M=M.substring(0,2) ;
System.out.println("M: "+M) ;
A=A.substring(2,4) ;
System.out.println("A: "+A) ;
rfc=P+Ma+N+A+M+D;
text11.setText(rfc.toUpperCase()+" " ) ;
p[cont-1].setRfc(rfc) ;
}
}) ;
butG.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
p[cont]=new Persona();
p[cont].setNombre(text1.getText() ) ;
p[cont].setApePat(text2.getText() ) ;
p[cont].setApeMat(text3.getText() ) ;
p[cont].setDiaNac(Integer.parseInt(text4.getText() ) ) ;
p[cont].setMesNac(Integer.parseInt(text5.getText() ) ) ;
p[cont].setAñoNac(Integer.parseInt(text6.getText() ) ) ;
p[cont].setDiaAct(Integer.parseInt(text7.getText() ) ) ;
p[cont].setMesAct(Integer.parseInt(text8.getText() ) ) ;
p[cont].setAñoAct(Integer.parseInt(text9.getText() ) ) ;
//p[cont].calcEdad(Integer.parseInt(text10.getText() ) ) ;
p[cont].setRfc(text11.getText() ) ;
cont++;
}
} ) ;
butL.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
text1.setText( "" ) ;
text2.setText( "" ) ;
text3.setText( "" ) ;
text4.setText( "" ) ;
text5.setText( "" ) ;
text6.setText( "" ) ;
text7.setText( "" ) ;
text8.setText( "" ) ;
text9.setText( "" ) ;
text10.setText( "" ) ;
text11.setText( "" ) ;
}
} ) ;
butR.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String cad="Nombre ApellidoP ApellidoM DiaN MesN AñoN DiaP MesP AñoP Edad RFCn";
for(int i=0; i<cont; i++){
cad=cad+p.getNombre()+" "+p.getApePat()
+" "+p.getApeMat()+" "+p.getDiaNac()
+" "+p.getMesNac()+" "+p.getAñoNac()+" "
+p.getDiaAct()+" "+p.getMesAct()+" "+p.getAñoAct()
+" "+p.calcEdad()+" "+p.getRfc()+ "n";
}
JOptionPane.showMessageDialog(null,cad,"Reporte",JOptionPane.INFORMATION_MESSAGE);
}
} ) ;
butS.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
} ) ;
}
public static void main (String args[]){
MainPersona mc=new MainPersona();
}
}
Nota:Esto esta hecho en el programa de GEL. Aparte hay ; ( y "" que estan separadas eso es por causa de los emoticones les recomiendo que los junten porque cuando quieres depurar el programa puede que por estos te marque errores.
Espero y les sirva el codigo

