ayuda

leofcksk8
05 de Mayo del 2006
hola tengo la siguiente aplicacion quiero que me genere un consecutivo pero me genera siempre el mismo.

/*
* Fileplain.java
*
* Created on 22 de diciembre de 2005, 09:23 AM
*
*/
package pryarcplan;
import java.io.*;
import javax.swing.*;
/**
*
* @author CLJ
*/
// Referenced classes of package pryarcplan:
// Icontrol, Formas, BodyAP, CabAP
class FilePlain
implements Icontrol
{
FilePlain(String id)
{
identidad = id;
_S_ = System.getProperty("file.separator");
_n = System.getProperty("line.separator");
}
protected final String getID()
{
return identidad;
}
protected final void setID(String identid)
{
identidad = identid;
}
protected final synchronized void buscaDirDEFAULT()throws Exception{
File pathDir = new File("control");
if(!pathDir.exists())
try
{
pathDir.mkdir();
}
catch(SecurityException err)
{
System.err.println("Denegado servicio. Consulte con el Administrador");
err.printStackTrace();
throw new Exception("Denegado servicio. Consulte con el Administrador");
}
else
System.out.println("Directorio OK!");
}
synchronized File crearArchivo(String nombreArchivo)throws Exception
{
boolean exito = false;
File arc = new File(nombreArchivo);
try
{
exito = arc.createNewFile();
}
catch(IOException err){
System.err.println("Error. I/O crearLog.");
err.printStackTrace();
throw new Exception("Error. I/O crearLog.");
}
catch(SecurityException err)
{
System.err.println("I/O Denegado. Consulte Administrador");
err.printStackTrace();
throw new Exception("I/O Denegado. Consulte Administrador");
}
return arc;
}
static synchronized void crearContLog(File log, String fecha)throws Exception{
int a1,m1;
try{
//puede que el estrin no sea un numero y arroja un error
a1 = Integer.parseInt(fecha.substring(0, 4));
m1 = Integer.parseInt(fecha.substring(4, 6));

//JOptionPane.showMessageDialog(null,log.getPath()+" - "+fecha);
DataOutputStream out = new DataOutputStream(new FileOutputStream(log));
try{
for(byte j = 0; j < Formas.noFrms(); j++)
{
out.writeByte(Formas.formatos[j]);
out.writeChar(9);
out.writeInt(0);
out.writeChar(9);
out.writeInt(a1);
out.writeChar(9);
out.writeInt(m1);
out.writeChars(_n);
}
out.close();
}catch(IOException err){
System.err.println("Error: IO Denegado crear ");
err.printStackTrace();
throw new Exception("Error: IO Denegado crear ");
}
}catch(FileNotFoundException err){
System.err.println("Error. Archivo no encontrado");
err.printStackTrace();
throw new Exception("Error. Archivo no encontrado");
}catch(NumberFormatException err){
System.err.println("Error. Archivo esta mal estructurado, por favor reviselo.");
err.printStackTrace();
throw new Exception("Error. Archivo esta mal estructurado, por favor reviselo.");
}
}
static final synchronized boolean crearLog(String nomArc, String fecha)throws Exception
{
boolean exito = false;
File log = new File(nomArc);
try
{
exito = log.createNewFile();
crearContLog(log, fecha);
}
catch(IOException err)
{
System.err.println("Error. I/O crearLog. \n"+err.getMessage());
err.printStackTrace();
throw new Exception("Error. I/O crearLog. \n"+err.getMessage());
}
catch(SecurityException err)
{
System.err.println("I/O Denegado. Consulte Administrador");
err.printStackTrace();
throw new Exception("I/O Denegado. Consulte Administrador \n"+err.getMessage());
}
return exito;
}
static final synchronized String abrirLog(String url, String arg[])throws Exception{
String sdato = "";
byte bfrmt = Byte.parseByte(arg[6]);
byte bdato[] = new byte[2];
int idato[][] = new int[2][3];
boolean eof = false;
try
{
DataInputStream in = new DataInputStream(new FileInputStream(url));
try
{
for(byte i = 0; i < bdato.length; i++)
{
bdato[i] = in.readByte();
in.readChar();
for(byte j = 0; j < idato[i].length; j++)
{
idato[i][j] = in.readInt();
in.readChar();
}
in.readChar();
}
in.close();
}
catch(EOFException err) {
throw new Exception(err.getMessage());
}
}
catch(IOException err){
throw new Exception(err.getMessage());

}
String fechaSist = arg[12];
int aF1oS=0,mesS=0;
try{
aF1oS = Integer.parseInt(fechaSist.substring(0, 4));
mesS = Integer.parseInt(fechaSist.substring(4, 6));
}catch(NumberFormatException err){
System.err.println("Error. Archivo esta mal estructurado, por favor reviselo.");
err.printStackTrace();
throw new Exception("Error. Archivo esta mal estructurado, por favor reviselo.");

}
if(bfrmt == bdato[0])
{
if(aF1oS == idato[0][1])
{
if(mesS == idato[0][2])
{
if(arg[5] == "02")
idato[0][0] = idato[0][0] + 1;
} else
{
idato[0][2] = mesS;
idato[0][0] = 0;
}
} else
{
idato[0][1] = aF1oS;
idato[0][2] = mesS;
idato[0][0] = 0;
}
try{
sdato = (new StringBuilder()).append(Integer.toString(idato[0][1])).append(Formas.poner_0s(idato[0][2], 2)).append(Formas.poner_0s(idato[0][0], 2)).toString();
}catch(NumberFormatException err){
System.err.println("Error. Archivo esta mal estructurado, por favor reviselo.");
err.printStackTrace();
throw new Exception("Error. Archivo esta mal estructurado, por favor reviselo.");
}
} else
if(bfrmt == bdato[1])
{
if(aF1oS == idato[1][1])
{
if(mesS == idato[1][2])
{
if(arg[5] == "02")
idato[1][0] = idato[1][0] + 1;
} else
{
idato[1][2] = mesS;
idato[1][0] = 0;
}
} else
{
idato[1][1] = aF1oS;
idato[1][2] = mesS;
idato[1][0] = 0;
}
try{
sdato = (new StringBuilder()).append(Integer.toString(idato[1][1])).append(Formas.poner_0s(idato[1][2], 2)).append(Formas.poner_0s(idato[1][0], 2)).toString();
}catch(NumberFormatException err){
System.err.println("Error. Archivo esta mal estructurado, por favor reviselo.");
err.printStackTrace();
throw new Exception("Error. Archivo esta mal estructurado, por favor reviselo.");
}
} else
{
System.out.println("error archivo alterado");
}
try
{
DataOutputStream in = new DataOutputStream(new FileOutputStream(url));
for(byte i = 0; i < bdato.length; i++)
{
in.writeByte(bdato[i]);
in.writeChar(9);
in.writeInt(idato[i][0]);
in.writeChar(9);
in.writeInt(idato[i][1]);
in.writeChar(9);
in.writeInt(idato[i][2]);
in.writeChars(_n);
}
in.close();
}
catch(IOException err) {
throw new Exception(err.getMessage());
}
return sdato;

}
final synchronized String buscArc(String formato[], String fecha)throws Exception{
boolean sehizo = false;
String url = (new StringBuilder()).append("control").append(_S_).append(getID()).append(".log").toString();
String sNoConsecutivo = "";
File archivo = new File(url);
if(!archivo.exists()){
sehizo = crearLog(url, fecha);
//System.out.println(sehizo);
if(sehizo)
sNoConsecutivo = abrirLog(url, formato);

///System.out.println(sNoConsecutivo+" - existe "+url);
}else{
//sNoConsecutivo = abrirLog(url, formato);//antes
sNoConsecutivo = (Integer.parseInt(abrirLog(url, formato)))+"";//cambiado Abril - 6 - 2006
//para aumentar el consecutivo
//System.out.println(sNoConsecutivo+" - no existe "+ url);
}

//NOTA: esta variable es la del consecutivo se aumenta si es el segundo archivo generado
return sNoConsecutivo;
}
protected void unirArchivos(File ff1, File ff2, File fdto)
throws IOException
{
FileReader f1 = new FileReader(ff1);
FileReader f2 = new FileReader(ff2);
FileWriter f3 = new FileWriter(fdto);
int c;
while((c = f1.read()) != -1)
f3.write(c);
while((c = f2.read()) != -1)
f3.write(c);
f1.close();
f2.close();
f3.close();
}
public static void organizaFP(String frmt[], String archtxtfte)throws Exception
{
FilePlain fp = new FilePlain((new StringBuilder()).append(frmt[1]).append(frmt[2]).toString());
fp.buscaDirDEFAULT();
frmt[9] = fp.buscArc(frmt, frmt[12]);

String nomArchtxt = "";
for(byte i = 0; i < 11; i++){
nomArchtxt = (new StringBuilder()).append(nomArchtxt).append(frmt[i]).toString();
//JOptionPane.showMessageDialog(null,frmt[i]+" i= "+i);
}

String dir_url = (new StringBuilder()).append(frmt[16]).append(_S_).append(nomArchtxt).toString();


frmt[16] = "";
try
{
String datosCuerpo[] = new String[2];
File fArchivoPlano_txt = fp.crearArchivo(dir_url);
File archtmp = new File("tmp");
File _tmp = archtmp;
File farchtmp2 = File.createTempFile("crp", null);
datosCuerpo = BodyAP.mainCuerpo(archtxtfte, farchtmp2, frmt[6]);

frmt[14] = datosCuerpo[0];
frmt[15] = datosCuerpo[1];
File _tmp1 = archtmp;
File farchtmp1 = File.createTempFile("crp", null);
CabAP.mainEncabezado(frmt, farchtmp1);
fp.unirArchivos(farchtmp1, farchtmp2, fArchivoPlano_txt);
farchtmp2.delete();
farchtmp1.delete();
archtmp.delete();
}
catch(IOException err){
err.printStackTrace();
throw new Exception(err.getMessage());
}
}
private String identidad;
protected static String _S_;
protected static String _n;
}
este es el que crea el archivo, aqui debe generar un numero de consecutivo al final que es con la fecha osea que debe quedar de esta forma es un largero el nombre del archivo pero el final es este dependiendo del mes si es mayo es 500 y el otro tendria que ser 501, pero siempre me genera el mismo 500 en los dos
---------------------------------------------------------------------------
package pryarcplan;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.*;
import javax.swing.border.*;
public class Ventana extends JFrame
{
public Ventana()
{
arg = new String[11];
initComponents();
}
private void initComponents()
{
JPanel jPnl1 = new JPanel();
lblR1 = new JLabel();
tpoRem = new JComboBox();
lblR2 = new JLabel();
codRem = new JTextField();
jPnl2 = new JPanel();
lblD1 = new JLabel();
tpoDes = new JComboBox();
lblD2 = new JLabel();
des = new JComboBox();
jPnlC1 = new JPanel();
lblF1 = new JLabel();
opera = new JComboBox();
lblF2 = new JLabel();
forma = new JComboBox();
jPnlC2 = new JPanel();
jPnlEnvio = new JPanel();
lblA = new JLabel();
AF1o = new JComboBox();
jPnlCv = new JPanel();
lblS1 = new JLabel();
pssP = new JPasswordField();
lblS2 = new JLabel();
pssD = new JPasswordField();
jPnlPP = new JPanel();
jLabel1 = new JLabel();
tfOrigen = new JTextField();
btnO = new JButton();
jLabel2 = new JLabel();
tfDestino = new JTextField();
btnD = new JButton();
jPnlF = new JPanel();
Ejecutar = new JButton();
jButton1 = new JButton();
tfVisor = new JTextField();
getContentPane().setLayout(new GridLayout(6, 1));
setDefaultCloseOperation(3);
setTitle("JCL, Modulo de Generar Archivo DIAN");
setResizable(false);
jPnl1.setBackground(color2);
jPnl1.setBorder(new TitledBorder(new EtchedBorder(0), " Remitente ", 0, 0, new Font("SansSerif", 1, 12)));
jPnl1.setToolTipText("Remitente");
jPnl1.setAutoscrolls(true);
lblR1.setLabelFor(tpoRem);
lblR1.setText("Tipo ");
lblR1.setToolTipText("");
lblR1.setAlignmentX(0.5F);
lblR1.setPreferredSize(new Dimension(32, 16));
jPnl1.add(lblR1);
tpoRem.setModel(new DefaultComboBoxModel(new String[] {
"70"
}));
tpoRem.setSelectedItem("70");
tpoRem.setToolTipText("Tipo de Remitente");
tpoRem.setEnabled(false);
tpoRem.setMinimumSize(new Dimension(52, 24));
tpoRem.setName("TipoRemitente");
tpoRem.setPreferredSize(new Dimension(55, 24));
jPnl1.add(tpoRem);
lblR2.setHorizontalAlignment(4);
lblR2.setText("C\363digo ");
lblR2.setAlignmentX(0.5F);
lblR2.setPreferredSize(new Dimension(60, 16));
jPnl1.add(lblR2);
codRem.setHorizontalAlignment(2);
codRem.setText(remitente);
codRem.setEditable(false);
codRem.setToolTipText("C\363digo de Remitente");
codRem.setMinimumSize(new Dimension(40, 22));
codRem.setName("");
codRem.setPreferredSize(new Dimension(40, 22));
jPnl1.add(codRem);
getContentPane().add(jPnl1);
jPnl2.setBackground(color2);
jPnl2.setBorder(new TitledBorder(new EtchedBorder(0), " Destinatario ", 0, 0, new Font("SansSerif", 1, 12)));
jPnl2.setToolTipText("Destinatario");
jPnl2.setAutoscrolls(true);
lblD1.setHorizontalAlignment(4);
lblD1.setLabelFor(tpoDes);
lblD1.setText("Tipo ");
lblD1.setMinimumSize(new Dimension(40, 16));
lblD1.setPreferredSize(new Dimension(50, 15));
jPnl2.add(lblD1);
tpoDes.setModel(new DefaultComboBoxModel(new String[] {
"Organismo Oficial"
}));
tpoDes.setToolTipText("Tipo de Destinatario");
tpoDes.setAutoscrolls(true);
tpoDes.setPreferredSize(new Dimension(130, 23));
jPnl2.add(tpoDes);
lblD2.setHorizontalAlignment(4);
lblD2.setLabelFor(des);
lblD2.setText("Nombre ");
lblD2.setPreferredSize(new Dimension(65, 16));
jPnl2.add(lblD2);
des.setModel(new DefaultComboBoxModel(new String[] {
"DIAN"
}));
des.setToolTipText("Nombre de Destinatario");
des.setAutoscrolls(true);
des.setPreferredSize(new Dimension(73, 24));
jPnl2.add(des);
getContentPane().add(jPnl2);
jPnlC1.setBackground(color1);
//jPnlC1.setBackground(new Color(210, 220, 255));
//jPnlC1.setBackground(new Color(2, 165, 165));
jPnlC1.setBorder(new TitledBorder(new EtchedBorder(0), " Formato ", 0, 0, new Font("Tahoma", 1, 11)));
jPnlC1.setToolTipText("Formato");
jPnlC1.setAutoscrolls(true);
lblF1.setHorizontalAlignment(0);
lblF1.setLabelFor(opera);
lblF1.setText("Operación ");
lblF1.setPreferredSize(new Dimension(62, 15));
jPnlC1.add(lblF1);
opera.setModel(new DefaultComboBoxModel(new String[] {
"Adición", "Modificación"
}));
opera.setToolTipText("Seleccion de operacion");
opera.setOpaque(false);
opera.setPreferredSize(new Dimension(120, 24));
jPnlC1.add(opera);
lblF2.setHorizontalAlignment(4);
lblF2.setLabelFor(forma);
lblF2.setText("Tipo ");
lblF2.setPreferredSize(new Dimension(66, 15));
jPnlC1.add(lblF2);
forma.setModel(new DefaultComboBoxModel(new String[] {
"Compra", "Venta"
}));
forma.setToolTipText("Selecci\363n Tipo Formato");
jPnlC1.add(forma);
getContentPane().add(jPnlC1);
jPnlC2.setLayout(new GridLayout(2, 1));
jPnlC2.setBackground(color2);
jPnlC2.setAutoscrolls(true);
jPnlC2.setMinimumSize(new Dimension(135, 25));
jPnlC2.setPreferredSize(new Dimension(143, 25));
jPnlEnvio.setBackground(color1);
//jPnlEnvio.setBackground(new Color(2, 160, 160));
jPnlEnvio.setToolTipText("A\361o Formato");
lblA.setFont(new Font("Dialog", 1, 12));
lblA.setLabelFor(AF1o);
lblA.setText("A\321O ENVIO");
lblA.setPreferredSize(new Dimension(70, 16));
jPnlEnvio.add(lblA);
AF1o.setModel(new DefaultComboBoxModel(new String[] {
"2006", "2007", "2008", "2009"
}));
AF1o.setSelectedIndex(0);
AF1o.setToolTipText("A\361o de envio informaci\363n");
AF1o.setPreferredSize(new Dimension(60, 20));
jPnlEnvio.add(AF1o);
jPnlC2.add(jPnlEnvio);
jPnlCv.setLayout(new GridBagLayout());
jPnlCv.setBackground(color2);
jPnlCv.setBorder(new TitledBorder(null, " claves ", 0, 0, new Font("Arial", 0, 9)));
jPnlCv.setMinimumSize(new Dimension(332, 44));
jPnlCv.setPreferredSize(new Dimension(363, 50));
lblS1.setHorizontalAlignment(0);
lblS1.setLabelFor(pssP);
lblS1.setText("Profesional ");
lblS1.setHorizontalTextPosition(10);
lblS1.setMaximumSize(new Dimension(120, 18));
lblS1.setMinimumSize(new Dimension(120, 15));
lblS1.setPreferredSize(new Dimension(159, 12));
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(0, 0, 2, 0);
jPnlCv.add(lblS1, gridBagConstraints);
pssP.setFont(new Font("Dialog", 0, 12));
pssP.setText(semillaPro);
pssP.setToolTipText("Semilla o clave del profesional");
pssP.setAutoscrolls(false);
pssP.setEditable(false);
pssP.setEnabled(true);
pssP.setMargin(new Insets(0, 1, 1, 1));
pssP.setMinimumSize(new Dimension(50, 18));
pssP.setPreferredSize(new Dimension(46, 20));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(0, 0, 6, 10);
jPnlCv.add(pssP, gridBagConstraints);
lblS2.setHorizontalAlignment(0);
lblS2.setLabelFor(pssD);
lblS2.setText(" DIAN ");
lblS2.setMaximumSize(new Dimension(100, 18));
lblS2.setMinimumSize(new Dimension(100, 16));
lblS2.setPreferredSize(new Dimension(100, 15));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(0, 5, 3, 0);
jPnlCv.add(lblS2, gridBagConstraints);
pssD.setFont(new Font("Dialog", 0, 12));
pssD.setText(semillaDian);
pssD.setToolTipText("Semilla o clave entregada de la DIAN");
pssD.setAutoscrolls(false);
pssD.setEditable(false);
pssD.setMargin(new Insets(0, 1, 1, 1));
pssD.setMinimumSize(new Dimension(50, 18));
pssD.setPreferredSize(new Dimension(46, 20));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(0, 0, 6, 50);
jPnlCv.add(pssD, gridBagConstraints);
jPnlC2.add(jPnlCv);
getContentPane().add(jPnlC2);
jPnlPP.setLayout(new GridBagLayout());
jPnlPP.setBackground(color2);
jPnlPP.setBorder(new TitledBorder(" Directorios / Ubicaci\363n "));
jPnlPP.setToolTipText("Archivos");
jPnlPP.setAutoscrolls(true);
jLabel1.setFont(new Font("Dialog", 0, 10));
jLabel1.setText("Archivo Origen");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.ipadx = 13;
gridBagConstraints.anchor = 17;
gridBagConstraints.insets = new Insets(0, 0, 0, 3);
jPnlPP.add(jLabel1, gridBagConstraints);
tfOrigen.setToolTipText("Ubicaci\363n del archivo Origen");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.ipadx = 170;
jPnlPP.add(tfOrigen, gridBagConstraints);
btnO.setBackground(color1);
btnO.setFont(new Font("Arial Narrow", 1, 11));
//btnO.setForeground(color2);
btnO.setText("Buscar");
btnO.setMnemonic(\'B\');
btnO.setAutoscrolls(true);
btnO.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt){

btnOActionPerformed(evt);
}
final Ventana this$0;
{
this$0 = Ventana.this;
// super();

}
});
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(2, 2, 2, 0);
jPnlPP.add(btnO, gridBagConstraints);
jLabel2.setFont(new Font("Dialog", 0, 10));
jLabel2.setText("Directorio Destino");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.ipadx = 1;
gridBagConstraints.anchor = 17;
gridBagConstraints.insets = new Insets(0, 0, 0, 3);
jPnlPP.add(jLabel2, gridBagConstraints);
tfDestino.setToolTipText("Ubicaci\363n de archivo resultado");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.ipadx = 170;
jPnlPP.add(tfDestino, gridBagConstraints);
btnD.setBackground(color1);
//btnD.setForeground(color2);
btnD.setFont(new Font("Arial Narrow", 1, 11));
btnD.setText("Buscar");
btnD.setMnemonic(\'u\');
btnD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
btnDActionPerformed(evt);
}
final Ventana this$0;
{
this$0 = Ventana.this;
// super();
}
});
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new Insets(2, 2, 2, 0);
jPnlPP.add(btnD, gridBagConstraints);
getContentPane().add(jPnlPP);
jPnlF.setBackground(color2);
jPnlF.setToolTipText("Jucef");
jPnlF.setAutoscrolls(true);
jPnlF.setMinimumSize(new Dimension(89, 30));
jPnlF.setPreferredSize(new Dimension(89, 30));
Ejecutar.setBackground(color1);
//Ejecutar.setForeground(color2);
Ejecutar.setText("Aceptar");
Ejecutar.setMnemonic(\'A\');
Ejecutar.setToolTipText("Ejecutar valores almacenados");
Ejecutar.setDebugGraphicsOptions(-1);
Ejecutar.setFocusTraversalPolicyProvider(true);
Ejecutar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt){
EjecutarActionPerformed(evt);

}
final Ventana this$0;
{
this$0 = Ventana.this;
// super();
}
});
jPnlF.add(Ejecutar);
jButton1.setBackground(color1);
//jButton1.setForeground(color2);
jButton1.setText("Salir");
jButton1.setMnemonic(\'S\');
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
jButton1ActionPerformed(evt);
}
final Ventana this$0;
{
this$0 = Ventana.this;
// super();
}
});
jPnlF.add(jButton1);
tfVisor.setColumns(30);
tfVisor.setEditable(false);
tfVisor.setFont(new Font("Dialog", 0, 10));
tfVisor.setHorizontalAlignment(0);
tfVisor.setText(empresa);
tfVisor.setBorder(new SoftBevelBorder(0));
tfVisor.setFocusable(false);
tfVisor.setName("visor");
tfVisor.setOpaque(false);
tfVisor.setRequestFocusEnabled(false);
tfVisor.setVerifyInputWhenFocusTarget(false);
jPnlF.add(tfVisor);
getContentPane().add(jPnlF);
pack();
}
private void jButton1ActionPerformed(ActionEvent evt)
{
System.exit(0);
}
private void EjecutarActionPerformed(ActionEvent evt)
{
if(opera.getSelectedItem().toString() == "Adici\363n"){
//VentanaConse vent = new VentanaConse(this);
//VentanaConse vent = new VentanaConse();
//EjecutarActionPerformed(evt);
procesar();
}

}

public void procesar(){
String valor = null;
String valor1 = null;
valor = validar(codRem.getText(), 4, \'D\');
if(valor != null)
{
valor1 = (new StringBuilder()).append(valor).append(" en Codigo Remitente\n").toString();
codRem.requestFocusInWindow();
codRem.selectAll();
}
valor = validar(pssP.getPassword(), 4, \'D\');
if(valor != null)
{
if(valor1 == null)
{
pssP.requestFocusInWindow();
valor1 = "";
pssP.selectAll();
}
valor1 = (new StringBuilder()).append(valor1).append(valor).append(" error en dato Profesional\n").toString();
}
valor = validar(pssD.getPassword(), 4, \'D\');
if(valor != null)
{
if(valor1 == null)
{
pssD.requestFocusInWindow();
valor1 = "";
pssD.selectAll();
}
valor1 = (new StringBuilder()).append(valor1).append(valor).append(" error en dato DIAN\n").toString();
}
if(tfOrigen.getText().length() < 3){
if(valor1 == null){
tfOrigen.requestFocusInWindow();
valor1 = "";
}
valor1 = (new StringBuilder()).append(valor1).append("No se ha cargado el Directorio en ORIGEN\n").toString();
}else{
File ft = new File(tfOrigen.getText());
if(!ft.isFile()){
if(valor1 == null){
tfOrigen.requestFocusInWindow();
valor1 = "";
}
valor1 = (new StringBuilder()).append(valor1).append("No se ha cargado el Directorio en ORIGEN\n").toString();
}
}
if(tfDestino.getText().length() < 3){
if(valor1 == null){
tfDestino.requestFocusInWindow();
valor1 = "";
}
valor1 = (new StringBuilder()).append(valor1).append("No se ha cargado el Directorio en DESTINO\n").toString();
} else{
File ft = new File(tfDestino.getText());
if(!ft.isDirectory()){
if(valor1 == null){
tfDestino.requestFocusInWindow();
valor1 = "";
}
valor1 = (new StringBuilder()).append(valor1).append("No se ha cargado el Directorio en DESTINO\n").toString();
}
}
if(valor1 != null){
//JOptionPane.showMessageDialog(this, valor1);
} else{
arg[0] = tpoRem.getSelectedItem().toString();
arg[1] = codRem.getText();
if(tpoDes.getSelectedItem().toString() == "Organismo Oficial")
arg[2] = "90";
if(des.getSelectedItem().toString() == "DIAN")
arg[3] = "001";
if(opera.getSelectedItem().toString() == "Adici\363n"){
arg[4] = "01";

}else
arg[4] = "02";
if(forma.getSelectedItem().toString() == "Compra")
arg[5] = "0032";
else
arg[5] = "0033";
arg[6] = AF1o.getSelectedItem().toString();
arg[7] = convert(pssP.getPassword());
arg[8] = convert(pssD.getPassword());
arg[9] = tfOrigen.getText();
arg[10] = tfDestino.getText();

try{
Main.main(arg);
}catch(Exception ex){
JOptionPane.showMessageDialog(this,"Error: "+ex.getMessage(),"Error de Archivo",JOptionPane.ERROR_MESSAGE);
}
tfVisor.setText(" OK ! ");
}
}

private synchronized String convert(char ac[])
{
String s = new String(ac);
return s;
}
private String validar(String s, int n, char D)
{
if(s != null)
{
int is = s.length();
for(byte p = 0; p < is; p++)
if(D == \'D\' && !Character.isDigit(s.charAt(p)))
return "Valores numericos";
if(is == n)
return null;
if(is < n)
return "Cadena Incompleta";
else
return "Cadena larga";
} else
{
return "Campo sin valor ";
}
}
private String validar(char c[], int n, char D)
{
int is = c.length;
for(byte p = 0; p < is; p++)
if(D == \'D\' && !Character.isDigit(c[p]))
return "Valores numericos";
if(is == n)
return null;
if(is < n)
return "Cadena Incompleta";
else
return "Cadena larga";
}
private void btnDActionPerformed(ActionEvent evt)
{
String nomDir = null;
JFileChooser selectArchD = new JFileChooser();
selectArchD.setFileSelectionMode(1);
int returnVal = selectArchD.showOpenDialog(this);
if(returnVal == 0)
{
nomDir = selectArchD.getCurrentDirectory().getPath();
selectArchD.getCurrentDirectory();
if(!nomDir.endsWith(File.separator))
{
selectArchD.getCurrentDirectory();
nomDir = (new StringBuilder()).append(nomDir).append(File.separator).toString();
}
}
tfDestino.setText(nomDir);
}
private void btnOActionPerformed(ActionEvent evt)
{
String nomArch = null;
String nomDir = null;
DFFilter fFiltro = new DFFilter("txt", "Archivos de Texto");
//JFileChooser selectArchO = new JFileChooser("C:");
JFileChooser selectArchO = new JFileChooser();
selectArchO.setFileFilter(fFiltro);
int returnVal = selectArchO.showOpenDialog(this);
if(returnVal == 0)
{
nomDir = selectArchO.getCurrentDirectory().getPath();
selectArchO.getCurrentDirectory();
if(!nomDir.endsWith(File.separator))
{
selectArchO.getCurrentDirectory();
nomDir = (new StringBuilder()).append(nomDir).append(File.separator).toString();
}
nomArch = selectArchO.getSelectedFile().getName();
}
if(nomDir == null)
{
nomDir = "";
nomArch = "";
}
tfOrigen.setText((new StringBuilder()).append(nomDir).append(nomArch).toString());
tfDestino.setText(nomDir);
}
public static void main(String args[]){
EventQueue.invokeLater(new Runnable() {
public void run()
{
(new Ventana()).setVisible(true);
}
});

}
public String remitente = "0147";
public String semillaPro = "2395";
public String semillaDian= "5252";
public String empresa = "D I V I S A S D E L L I T O R A L";

public static final String INCOMPLETO = "Cadena Incompleta";
public static final String NULO = "Cadena vacia";
public static final String LARGO = "Cadena larga";
public static final String FALLON = "Valores numericos";
public static final String FALLOE = "Campo sin valor ";
public Color color1=new Color(26,150,217);
public Color color2=new Color(231,231,235);
private String arg[];
private JComboBox AF1o;
private JButton Ejecutar;
private JButton btnD;
private JButton btnO;
private JTextField codRem;
private JComboBox des;
private JComboBox forma;
private JButton jButton1;
private JLabel jLabel1;
private JLabel jLabel2;
private JPanel jPnl2;
private JPanel jPnlC1;
private JPanel jPnlC2;
private JPanel jPnlCv;
private JPanel jPnlEnvio;
private JPanel jPnlF;
private JPanel jPnlPP;
private JLabel lblA;
private JLabel lblD1;
private JLabel lblD2;
private JLabel lblF1;
private JLabel lblF2;
private JLabel lblR1;
private JLabel lblR2;
private JLabel lblS1;
private JLabel lblS2;
private JComboBox opera;
private JPasswordField pssD;
private JPasswordField pssP;
private JTextField tfDestino;
private JTextField tfOrigen;
private JTextField tfVisor;
private JComboBox tpoDes;
private JComboBox tpoRem;
}
y aqui es donde ejecuto el prog, si necesitan las demas clases por favor me dicen y de una las envio, pq es un proyecto final

Diego
05 de Mayo del 2006
Tu la longitud de tu código 'espanta' al que lo lea. Omite el código de la interfaz gráfica, de la entrada/salida de archivo y muestra el código que debería hacer " que me genere un consecutivo ", y explícate que entiendes por consecutivo ¿número consecutivo?. Explícate un poco mejor y podremos ayudarte.