[ Foro de Python ]

AYUDA CON ERROR EN NEDTBEANS

25-Jun-2021 16:42
Invitado ( ALEXIS)
0 Respuestas

NECESITO UNA AYUDA CON ESTE ERROR EN NEDTBEANS

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "24000000,00"
at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.base/java.lang.Double.parseDouble(Double.java:556)
at Formularios.FrmFacturas.sumarTotal(FrmFacturas.java:466)
at Formularios.FrmFacturas.tblFacturasKeyPressed(FrmFacturas.java:497)
at Formularios.FrmFacturas$3.keyPressed(FrmFacturas.java:161)
at java.desktop/java.awt.AWTEventMulticaster.keyPressed(AWTEventMulticaster.java:258)
at java.desktop/java.awt.Component.processKeyEvent(Component.java:6575)
at java.desktop/javax.swing.JComponent.processKeyEvent(JComponent.java:2849)
at java.desktop/java.awt.Component.processEvent(Component.java:6394)
at java.desktop/java.awt.Container.processEvent(Container.java:2264)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4993)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2322)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4825)
at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1950)
at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:875)
at java.desktop/java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1144)
at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1014)
at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:840)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4874)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2322)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4825)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


ESTE ES EL CODIGO:

package Formularios;

import Datos.DAlmacen;
import Datos.DDetalleFacturas;
import Datos.DFactura;
import Logica.LAlmacen;
import Logica.LDetalleFacturas;
import Logica.LFactura;
import java.awt.event.KeyEvent;
import java.sql.Date;
import java.text.DecimalFormat;
import java.util.Calendar;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
*
* @author kikin
*/
public final class FrmFacturas extends javax.swing.JInternalFrame {

   DefaultTableModel miModelo;
   static int idlineas = 0;

   public static void setProveedores(String id, String proveedor) {
       txtIdProveedores.setText(id);
       txtProveedor.setText(proveedor);
   }

   public static void setLinea(String id, String linea) {
       idlineas = Integer.parseInt(id);
       txtIdLineas.setText(id);
       txtLinea.setText(linea);
   }

   /**
    * Creates new form FrmFacturas
    */
   public FrmFacturas() {
       initComponents();
       habilitar(true);
       jLabel1.setVisible(false);
       txtIdFacturas.setVisible(false);
       txtIdLineas.setVisible(false);
       txtIdProveedores.setVisible(false);
       txtTotal.setEditable(false);
       miModelo = (DefaultTableModel) tblFacturas.getModel();

       tblFacturas.getColumn("CODIGO").setWidth(15);
       tblFacturas.getColumn("CODIGO").setPreferredWidth(15);

       tblFacturas.getColumn("DESCRIPCION").setWidth(220);
       tblFacturas.getColumn("DESCRIPCION").setPreferredWidth(220);

       tblFacturas.getColumn("CANTIDAD").setWidth(20);
       tblFacturas.getColumn("CANTIDAD").setPreferredWidth(20);

       tblFacturas.getColumn("U/MEDIDA").setWidth(20);
       tblFacturas.getColumn("U/MEDIDA").setPreferredWidth(20);

       tblFacturas.getColumn("P/UNITARIO").setWidth(20);
       tblFacturas.getColumn("P/UNITARIO").setPreferredWidth(20);

       tblFacturas.getColumn("TOTAL").setWidth(20);
       tblFacturas.getColumn("TOTAL").setPreferredWidth(20);

       txtIdLineas.setEnabled(false);
       txtIdProveedores.setEnabled(false);

   }

   public void habilitar(boolean b) {
       txtEnter.setEnabled(!b);
       txtFecha.setEnabled(!b);
       txtLinea.setEnabled(!b);
       txtProveedor.setEnabled(!b);
       btnCancelar.setEnabled(!b);
       btnGuardar.setEnabled(!b);
       btnBuscarLinea.setEnabled(!b);
       btnBuscarProveedor.setEnabled(!b);
       btnNuevo.setEnabled(b);

   }

   /**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */
   @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
   private void initComponents() {

       jPanel1 = new javax.swing.JPanel();
       jLabel1 = new javax.swing.JLabel();
       jLabel2 = new javax.swing.JLabel();
       jLabel3 = new javax.swing.JLabel();
       jLabel4 = new javax.swing.JLabel();
       txtIdFacturas = new javax.swing.JTextField();
       txtLinea = new javax.swing.JTextField();
       txtProveedor = new javax.swing.JTextField();
       btnBuscarLinea = new javax.swing.JButton();
       btnBuscarProveedor = new javax.swing.JButton();
       jScrollPane1 = new javax.swing.JScrollPane();
       tblFacturas = new javax.swing.JTable();
       btnNuevo = new javax.swing.JButton();
       btnGuardar = new javax.swing.JButton();
       btnCancelar = new javax.swing.JButton();
       txtIdLineas = new javax.swing.JTextField();
       txtIdProveedores = new javax.swing.JTextField();
       txtFecha = new com.toedter.calendar.JDateChooser();
       txtEnter = new javax.swing.JTextField();
       txtTotal = new javax.swing.JTextField();
       jLabel5 = new javax.swing.JLabel();

       setClosable(true);
       setIconifiable(true);
       setMaximizable(true);
       setPreferredSize(new java.awt.Dimension(750, 530));

       jPanel1.setBackground(new java.awt.Color(153, 153, 255));

       jLabel1.setText("ID:");

       jLabel2.setText("LINEA:");

       jLabel3.setText("PROVEEDOR:");

       jLabel4.setText("FECHA:");

       btnBuscarLinea.setText("...");
       btnBuscarLinea.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               btnBuscarLineaActionPerformed(evt);
           }
       });

       btnBuscarProveedor.setText("...");
       btnBuscarProveedor.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               btnBuscarProveedorActionPerformed(evt);
           }
       });

       tblFacturas.setModel(new javax.swing.table.DefaultTableModel(
           new Object [][] {

           },
           new String [] {
               "CODIGO", "DESCRIPCION", "CANTIDAD", "U/MEDIDA", "P/UNITARIO", "TOTAL"
           }
       ));
       tblFacturas.addKeyListener(new java.awt.event.KeyAdapter() {
           public void keyPressed(java.awt.event.KeyEvent evt) {
               tblFacturasKeyPressed(evt);
           }
       });
       jScrollPane1.setViewportView(tblFacturas);

       btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Nuevo.png"))); // NOI18N
       btnNuevo.setText("Nuevo");
       btnNuevo.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               btnNuevoActionPerformed(evt);
           }
       });

       btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Guardar.jpg"))); // NOI18N
       btnGuardar.setText("Guardar");
       btnGuardar.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               btnGuardarActionPerformed(evt);
           }
       });

       btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cancelar.png"))); // NOI18N
       btnCancelar.setText("Cancelar");
       btnCancelar.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               btnCancelarActionPerformed(evt);
           }
       });

       txtEnter.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
       txtEnter.addKeyListener(new java.awt.event.KeyAdapter() {
           public void keyPressed(java.awt.event.KeyEvent evt) {
               txtEnterKeyPressed(evt);
           }
       });

       txtTotal.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
       txtTotal.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
       txtTotal.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               txtTotalActionPerformed(evt);
           }
       });

       jLabel5.setText("TOTAL:");

       javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
       jPanel1.setLayout(jPanel1Layout);
       jPanel1Layout.setHorizontalGroup(
           jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel1Layout.createSequentialGroup()
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addGap(55, 55, 55)
                       .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                           .addComponent(jLabel4)
                           .addComponent(jLabel3)
                           .addComponent(jLabel2)
                           .addComponent(jLabel1))
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                       .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                           .addComponent(txtProveedor, javax.swing.GroupLayout.Alignment.LEADING)
                           .addComponent(txtIdFacturas, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                           .addComponent(txtLinea, javax.swing.GroupLayout.Alignment.LEADING)
                           .addComponent(txtFecha, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE))
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                       .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                           .addComponent(btnBuscarLinea, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                           .addComponent(btnBuscarProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                       .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                           .addComponent(txtIdLineas)
                           .addComponent(txtIdProveedores, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addContainerGap()
                       .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 717, javax.swing.GroupLayout.PREFERRED_SIZE))
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addContainerGap()
                       .addComponent(txtEnter, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)))
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
           .addGroup(jPanel1Layout.createSequentialGroup()
               .addContainerGap()
               .addComponent(btnNuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(36, 36, 36)
               .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(27, 27, 27)
               .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addComponent(jLabel5)
               .addGap(18, 18, 18)
               .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(19, 19, 19))
       );
       jPanel1Layout.setVerticalGroup(
           jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel1Layout.createSequentialGroup()
               .addGap(44, 44, 44)
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                   .addComponent(jLabel1)
                   .addComponent(txtIdFacturas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addGap(18, 18, 18)
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                   .addComponent(jLabel2)
                   .addComponent(txtLinea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(btnBuscarLinea)
                   .addComponent(txtIdLineas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addGap(18, 18, 18)
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                   .addComponent(jLabel3)
                   .addComponent(txtProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(btnBuscarProveedor)
                   .addComponent(txtIdProveedores, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addGap(18, 18, 18)
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                   .addComponent(txtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(jLabel4))
               .addGap(32, 32, 32)
               .addComponent(txtEnter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(18, 18, 18)
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(btnNuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(jLabel5))
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
       );

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addContainerGap())
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap()
               .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
       );

       pack();
   }// </editor-fold>                        

   private void btnBuscarLineaActionPerformed(java.awt.event.ActionEvent evt) {                                              
       // TODO add your handling code here:
       FrmBuscarLineas mi = new FrmBuscarLineas(new JFrame(), true);
       mi.setLocationRelativeTo(null);
       mi.setVisible(true);

   }                                              

   private void btnBuscarProveedorActionPerformed(java.awt.event.ActionEvent evt) {                                                  
       // TODO add your handling code here:
       FrmBuscarProveedores mi = new FrmBuscarProveedores(new JFrame(), true);
       mi.setLocationRelativeTo(null);
       mi.setVisible(true);
   }                                                  

   private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {                                        
       // TODO add your handling code here:
       habilitar(false);
   }                                        

   private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {                                          
       // TODO add your handling code here:
       String msg = "", msgfinal = "";
       if (txtLinea.getText().equals("")) {
           JOptionPane.showMessageDialog(rootPane, "Campo linea obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
           txtLinea.requestFocusInWindow();
           return;
       }
       if (txtProveedor.getText().equals("")) {
           JOptionPane.showMessageDialog(rootPane, "Campo proveedor obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
           txtProveedor.requestFocusInWindow();
           return;
       }
       if (txtFecha.getDate() == null) {
           JOptionPane.showMessageDialog(rootPane, "Campo fecha obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
           txtFecha.requestFocusInWindow();
           return;
       }

       LFactura fn = new LFactura();
       DFactura dts = new DFactura();
       dts.setLineasId(Integer.parseInt(txtIdLineas.getText()));

       dts.setProveedoresId(Integer.parseInt(txtIdProveedores.getText()));

       Calendar cal;

       cal = txtFecha.getCalendar();

       int aa, mm, dd;

       aa = cal.get(Calendar.YEAR) - 1900;
       mm = cal.get(Calendar.MONTH);
       dd = cal.get(Calendar.DAY_OF_MONTH);

       dts.setFechaEntrada(new Date(aa, mm, dd));
       txtProveedor.setText("");
       txtLinea.setText("");
       txtLinea.setEnabled(false);
       txtProveedor.setEnabled(false);        
       int idfact = fn.insertarFacturas(dts);

       if (idfact > 0) {
           int filas = tblFacturas.getRowCount();
           for (int i = 0; i < filas; i++) {
               String idprod = tblFacturas.getValueAt(i, 0).toString();
               String descrip = tblFacturas.getValueAt(i, 1).toString();
               int cantidad = Integer.parseInt(tblFacturas.getValueAt(i, 2).toString());
               String umedida = tblFacturas.getValueAt(i, 3).toString();
               double punitario = Double.parseDouble(tblFacturas.getValueAt(i, 4).toString());
               double total = Double.parseDouble(tblFacturas.getValueAt(i, 5).toString());

               LDetalleFacturas fundf = new LDetalleFacturas();
               DDetalleFacturas dtsf = new DDetalleFacturas();
               dtsf.setFacturasId(idfact);
               dtsf.setProductosId(idprod);
               dtsf.setCantidad(cantidad);
               dtsf.setTotal(total);

               String mensaje = fundf.registrarDetalleFactura(dtsf);

               if (mensaje.equals("si")) {
                   LAlmacen funAl = new LAlmacen();
                   DAlmacen dtsp = new DAlmacen();

                   dtsp.setIdAlmacen(idprod);
                   dtsp.setDescripcion(descrip);
                   dtsp.setStock(cantidad);
                   dtsp.setUMedida(umedida);
                   dtsp.setPUnitario(punitario);
                   dtsp.setLineasId(idlineas);

                   msgfinal = funAl.insertarProductos(dtsp);

               }

           }
           JOptionPane.showMessageDialog(rootPane, msgfinal, "Información", JOptionPane.INFORMATION_MESSAGE);

       } else {
           JOptionPane.showMessageDialog(rootPane, "Ocurio un problema al insertar", "Información", JOptionPane.ERROR_MESSAGE);
       }
       limpiar();
       habilitar(true);


   }                                          
   public void limpiar() {
       txtLinea.setText("m");
       txtEnter.setText("");
       txtFecha.setDate(null);
       txtProveedor.setText("m");
       txtIdFacturas.setText("");
       txtIdLineas.setText("");
       txtIdProveedores.setText("");
       txtTotal.setText("");
       try {
           DefaultTableModel modelo = (DefaultTableModel) tblFacturas.getModel();
           int filas = tblFacturas.getRowCount();
           for (int i = 0; filas > i; i++) {
               modelo.removeRow(0);
           }
       } catch (Exception e) {
           JOptionPane.showMessageDialog(null, "Error al limpiar la tabla.");
       }
   }
   private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {                                            
       // TODO add your handling code here:
       habilitar(true);
   }                                          

   public boolean estaenTabla(String texto) {
       boolean res = false;
       DecimalFormat ft = new DecimalFormat("####.00");
       for (int i = 0; i < tblFacturas.getRowCount(); i++) {
           String codigo = tblFacturas.getValueAt(i, 0).toString();
           if (codigo.equals(texto)) {
               int cantidad = Integer.parseInt(tblFacturas.getValueAt(i, 2).toString());
               double preciounitario = Double.parseDouble(tblFacturas.getValueAt(i, 4).toString());
               int totalcantidad = cantidad + 1;
               tblFacturas.setValueAt(totalcantidad, i, 2);

               double totalparcial = totalcantidad * preciounitario;
               tblFacturas.setValueAt(ft.format(totalparcial), i, 5);
               res = true;
           }
       }
       sumarTotal();
       return res;
   }

   public void sumarTotal() {
       DecimalFormat ft = new DecimalFormat("####.00");
       double totalparcial = 0, totalfinal = 0;
       for (int i = 0; i < tblFacturas.getRowCount(); i++) {
           totalparcial = Double.parseDouble(tblFacturas.getValueAt(i, 5).toString());
           totalfinal += totalparcial;
           txtTotal.setText(ft.format(totalfinal));
       }

   }
   private void txtEnterKeyPressed(java.awt.event.KeyEvent evt) {                                    
       // TODO add your handling code here:
       if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
           boolean b = estaenTabla(txtEnter.getText());
           if (b == false) {
               mostrarProductos(txtEnter.getText());
           }
           sumarTotal();
           txtEnter.setText("");
       }


   }                                  

   private void tblFacturasKeyPressed(java.awt.event.KeyEvent evt) {                                      
       // TODO add your handling code here:
       DecimalFormat ft = new DecimalFormat("####.00");
       if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
           for (int i = 0; i < tblFacturas.getRowCount(); i++) {
               int cantidad = Integer.parseInt(tblFacturas.getValueAt(i, 2).toString());
               double preciounitario = Double.parseDouble(tblFacturas.getValueAt(i, 4).toString());

               double totalparcial = cantidad * preciounitario;
               tblFacturas.setValueAt(ft.format(totalparcial), i, 5);
           }
           sumarTotal();
       }
   }                                      

   private void txtTotalActionPerformed(java.awt.event.ActionEvent evt) {                                        
       // TODO add your handling code here:
   }                                        

   public void mostrarProductos(String producto) {
       LAlmacen fn = new LAlmacen();
       DAlmacen dts = new DAlmacen();
       DefaultTableModel tblDatos = (DefaultTableModel) tblFacturas.getModel();
       dts.setIdAlmacen(producto);
       String registros[] = fn.mostrarbuscarProductos(dts);
       if (registros[0] != null) {
           tblDatos.insertRow(0, registros);
           tblFacturas.setModel(tblDatos);
       } else {
           registros[0] = txtEnter.getText();
           registros[1] = "";
           registros[2] = "1";
           registros[3] = "";
           registros[4] = "0.00";
           registros[5] = "0.00";
           tblDatos.insertRow(0, registros);
           tblFacturas.setModel(tblDatos);
       }

   }

   // Variables declaration - do not modify                    
   private javax.swing.JButton btnBuscarLinea;
   private javax.swing.JButton btnBuscarProveedor;
   private javax.swing.JButton btnCancelar;
   private javax.swing.JButton btnGuardar;
   private javax.swing.JButton btnNuevo;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JLabel jLabel2;
   private javax.swing.JLabel jLabel3;
   private javax.swing.JLabel jLabel4;
   private javax.swing.JLabel jLabel5;
   private javax.swing.JPanel jPanel1;
   private javax.swing.JScrollPane jScrollPane1;
   private javax.swing.JTable tblFacturas;
   private javax.swing.JTextField txtEnter;
   private com.toedter.calendar.JDateChooser txtFecha;
   private javax.swing.JTextField txtIdFacturas;
   public static javax.swing.JTextField txtIdLineas;
   public static javax.swing.JTextField txtIdProveedores;
   public static javax.swing.JTextField txtLinea;
   public static javax.swing.JTextField txtProveedor;
   private javax.swing.JTextField txtTotal;
   // End of variables declaration                  

}





(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)