13/11/2006, 20:27
|
| | Fecha de Ingreso: noviembre-2006
Mensajes: 27
Antigüedad: 18 años, 2 meses Puntos: 0 | |
tienes razon debi poner parte del codigo sorry metodo que me abre el archivo
public static BufferedReader abrir(){
File f=new File("cuentas2.txt");
BufferedReader br=null;
try{
br=new BufferedReader(new FileReader(f));
}catch(IOException e){
}
return br;
}
metodo que lo usa(t1 y t2 son JTextField y ar2 es un arraylist)
private void debe(ActionEvent e){
BufferedReader br=abrir();
try{
String c=t1.getText();
String c1=t2.getText();
ar2.add(c);
//tamaño del texto que ingreso por t1
int x=c.length();
while(br.readLine()!=null){
String in=br.readLine();
String r=in.substring(0,x);
if(r.equals(c)){
String r1=in.substring(x,in.length());
ar.add(r1+" "+c1);
break;
}
}
br.close();
t1.setText("");
t2.setText("");
}catch(IOException e1){
}
}
este metodo muestra lo q guarde en el ArrayList y lo muestra en JTextArea claro habia otro ArrayList que es ar1 y ar
private void registrar(ActionEvent e){
String t=javax.swing.JOptionPane.showInputDialog("ingrese el codigo:");
cont++;
a.append("..................."+cont+"............. ."+"\n");
int i=ar.size();
for(int j=0;j<i;j++){
a.append((String)ar2.get(j)+" ");
a.append((String)ar.get(j)+"\n");
}
int i1=ar2.size();
for(int j=i;j<i1;j++){
a.append((String)ar2.get(j)+" ");
a.append((String)ar1.get(j-1)+"\n");
}
a.append(t+"\n");
ar.clear();
ar1.clear();
ar2.clear();
t1.setText("");
t2.setText("");
}
la primera vez que hago click me salle lo que quiero osea esto
...................1..............
10 caja y banco 2514
40 tributos por pagar 654
por la compra de mercaderia
pero cuando quiero volver hacer click en el boton me sale esta excepcion
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at contabilidad.Transaccion.debe(Transaccion.java:178 )
at contabilidad.Transaccion.access$2(Transaccion.java :169)
at contabilidad.Transaccion$3.actionPerformed(Transac cion.java:155)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source) |