Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.biosis.biosislite.vistas.inventario; import com.biosis.biosislite.entidades.inventario.Factura; import com.biosis.biosislite.controladores.inventario.AbstractControlador; import com.biosis.biosislite.controladores.inventario.FacturaControlador; import java.awt.Image; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import org.apache.commons.beanutils.BeanUtils; import org.jdesktop.beansbinding.AutoBinding; import org.jdesktop.beansbinding.BeanProperty; import org.jdesktop.observablecollections.ObservableCollections; import org.jdesktop.swingbinding.JTableBinding; import org.jdesktop.swingbinding.SwingBindings; /** * * @author Documentos */ public class MantenimientoFactura extends javax.swing.JInternalFrame { /** * Creates new form MantenimientoTipo */ private static MantenimientoFactura instancia; public MantenimientoFactura() { initComponents(); listar(); ImageIcon fot = new ImageIcon("img/no_disponible.png"); Icon icono = new ImageIcon(fot.getImage().getScaledInstance(lblFactura.getWidth(), lblFactura.getHeight(), Image.SCALE_DEFAULT)); lblFactura.setIcon(icono); FormularioUtil.activarComponente(panelDatos, false); FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); } public static MantenimientoFactura getInstancia() { if (instancia == null) { instancia = new MantenimientoFactura(); } return instancia; } /** * 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">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jLabel1 = new javax.swing.JLabel(); txtbuscar = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); tblFactura = new javax.swing.JTable(); panelDatos = new javax.swing.JPanel(); nombreLabel = new javax.swing.JLabel(); nombreField = new javax.swing.JTextField(); nombreLabel1 = new javax.swing.JLabel(); facturaField = new javax.swing.JTextField(); jButton2 = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); jDateFecha = new com.toedter.calendar.JDateChooser(); panelOpciones = new javax.swing.JPanel(); btnnuevo = new javax.swing.JButton(); btnmodificar = new javax.swing.JButton(); btneliminar = new javax.swing.JButton(); panelFoto = new javax.swing.JPanel(); lblFactura = new javax.swing.JLabel(); panelGuardar = new javax.swing.JPanel(); btnguardar = new javax.swing.JButton(); btncancelar = new javax.swing.JButton(); setClosable(true); setTitle("Mantenimiento de facturas"); java.awt.GridBagLayout layout = new java.awt.GridBagLayout(); layout.columnWidths = new int[] { 0, 7, 0, 7, 0, 7, 0 }; layout.rowHeights = new int[] { 0, 7, 0, 7, 0, 7, 0, 7, 0 }; getContentPane().setLayout(layout); jLabel1.setText("Buscar: "); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; getContentPane().add(jLabel1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.6; getContentPane().add(txtbuscar, gridBagConstraints); jButton1.setText("Buscar"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; getContentPane().add(jButton1, gridBagConstraints); jLabel2.setText("Lista de facturas"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; getContentPane().add(jLabel2, gridBagConstraints); tblFactura .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); tblFactura.setPreferredSize(new java.awt.Dimension(250, 64)); jScrollPane1.setViewportView(tblFactura); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.2; getContentPane().add(jScrollPane1, gridBagConstraints); panelDatos.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 1, 14))); // NOI18N panelDatos.setToolTipText(""); java.awt.GridBagLayout panelDatosLayout = new java.awt.GridBagLayout(); panelDatosLayout.columnWidths = new int[] { 0, 4, 0, 4, 0, 4, 0 }; panelDatosLayout.rowHeights = new int[] { 0, 4, 0, 4, 0, 4, 0, 4, 0 }; panelDatos.setLayout(panelDatosLayout); nombreLabel.setText("Numero: "); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; panelDatos.add(nombreLabel, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 261; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 0.1; panelDatos.add(nombreField, gridBagConstraints); nombreLabel1.setText("Ruta: "); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; panelDatos.add(nombreLabel1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 196; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 0.1; panelDatos.add(facturaField, gridBagConstraints); jButton2.setText("..."); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; panelDatos.add(jButton2, gridBagConstraints); jLabel3.setText("Fecha: "); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; panelDatos.add(jLabel3, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 8; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 103; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; panelDatos.add(jDateFecha, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; gridBagConstraints.weightx = 0.3; getContentPane().add(panelDatos, gridBagConstraints); panelOpciones.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Opciones", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 1, 14))); // NOI18N panelOpciones.setToolTipText(""); java.awt.GridBagLayout panelOpcionesLayout = new java.awt.GridBagLayout(); panelOpcionesLayout.columnWidths = new int[] { 0, 20, 0, 20, 0 }; panelOpcionesLayout.rowHeights = new int[] { 0 }; panelOpciones.setLayout(panelOpcionesLayout); btnnuevo.setText("Nuevo"); btnnuevo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnnuevoActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; panelOpciones.add(btnnuevo, gridBagConstraints); btnmodificar.setText("Modificar"); btnmodificar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnmodificarActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; panelOpciones.add(btnmodificar, gridBagConstraints); btneliminar.setText("Eliminar"); btneliminar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btneliminarActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; panelOpciones.add(btneliminar, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 3; getContentPane().add(panelOpciones, gridBagConstraints); panelFoto.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Foto", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 1, 14))); // NOI18N lblFactura .setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/iconosLogin/no_disponible.png"))); // NOI18N javax.swing.GroupLayout panelFotoLayout = new javax.swing.GroupLayout(panelFoto); panelFoto.setLayout(panelFotoLayout); panelFotoLayout.setHorizontalGroup(panelFotoLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelFotoLayout.createSequentialGroup() .addComponent(lblFactura, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE) .addContainerGap())); panelFotoLayout .setVerticalGroup(panelFotoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblFactura, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; gridBagConstraints.gridheight = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.3; gridBagConstraints.weighty = 0.2; getContentPane().add(panelFoto, gridBagConstraints); panelGuardar.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Acciones", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 1, 14))); // NOI18N java.awt.GridBagLayout panelGuardarLayout = new java.awt.GridBagLayout(); panelGuardarLayout.columnWidths = new int[] { 0, 7, 0 }; panelGuardarLayout.rowHeights = new int[] { 0 }; panelGuardar.setLayout(panelGuardarLayout); btnguardar.setText("Guardar"); btnguardar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnguardarActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.ipadx = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; panelGuardar.add(btnguardar, gridBagConstraints); btncancelar.setText("Cancelar"); btncancelar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btncancelarActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; panelGuardar.add(btncancelar, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 8; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(panelGuardar, gridBagConstraints); pack(); }// </editor-fold>//GEN-END:initComponents private void btnnuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnnuevoActionPerformed // TODO add your handling code here: accion = AbstractControlador.NUEVO; facturaControlador.prepararCrear(); FormularioUtil.activarComponente(panelOpciones, false); FormularioUtil.activarComponente(panelGuardar, true); FormularioUtil.activarComponente(panelDatos, true); nombreField.requestFocusInWindow(); }//GEN-LAST:event_btnnuevoActionPerformed private void btnmodificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnmodificarActionPerformed // TODO add your handling code here: accion = AbstractControlador.MODIFICAR; int fila = this.tblFactura.getSelectedRow(); if (fila != -1) { FormularioUtil.activarComponente(panelDatos, true); FormularioUtil.activarComponente(panelOpciones, false); FormularioUtil.activarComponente(panelGuardar, true); accion = AbstractControlador.MODIFICAR; facturaControlador.setSeleccionado(lista.get(fila)); Factura factura = facturaControlador.getSeleccionado(); try { nombreField.setText(BeanUtils.getProperty(factura, "numeroFactura")); facturaField.setText(BeanUtils.getProperty(factura, "ruta")); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) { Logger.getLogger(MantenimientoClase.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Tipo", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }//GEN-LAST:event_btnmodificarActionPerformed private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = AbstractControlador.ELIMINAR; if (tblFactura.getSelectedRow() != -1) { Integer codigo = tblFactura.getSelectedRow(); Factura factura = facturaControlador.buscarPorId(lista.get(codigo).getId()); if (factura != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblFactura.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Factura factura2 = lista.get(filas[0]); lista.remove(factura2); facturaControlador.setSeleccionado(factura2); facturaControlador.accion(accion); } if (facturaControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Tipo eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Tipo", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }//GEN-LAST:event_btneliminarActionPerformed private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed // TODO add your handling code here: List<Integer> array = new ArrayList(); array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.LETRA, this.nombreField, "Nombre")); FormularioUtil.validar2(array); if (FormularioUtil.error) { JOptionPane.showMessageDialog(null, FormularioUtil.mensaje, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); FormularioUtil.mensaje = ""; FormularioUtil.error = false; } else { String palabra = ""; String palabra2 = ""; if (accion == 1) { palabra = "registrar"; palabra2 = "registrado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { facturaControlador.getSeleccionado().setNumeroFactura(nombreField.getText()); facturaControlador.getSeleccionado().setFecha(jDateFecha.getDate()); facturaControlador.getSeleccionado().setRuta(facturaField.getText()); facturaControlador.accion(accion); lista.add(facturaControlador.getSeleccionado()); if (accion == 1) { JOptionPane.showMessageDialog(null, "Tipo " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else if (accion == 2) { palabra = "modificar"; palabra2 = "modificado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (accion == 2) { JOptionPane.showMessageDialog(null, "Tipo " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); lista.clear(); facturaControlador.getSeleccionado().setNumeroFactura(nombreField.getText()); facturaControlador.getSeleccionado().setFecha(jDateFecha.getDate()); facturaControlador.getSeleccionado().setRuta(facturaField.getText()); facturaControlador.accion(accion); listar(); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } FormularioUtil.limpiarComponente(panelDatos); FormularioUtil.limpiarComponente(panelFoto); FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); FormularioUtil.activarComponente(panelDatos, false); lblFactura.setIcon(null); } }//GEN-LAST:event_btnguardarActionPerformed private void btncancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btncancelarActionPerformed // TODO add your handling code here: FormularioUtil.activarComponente(panelDatos, false); FormularioUtil.limpiarComponente(panelDatos); FormularioUtil.limpiarComponente(panelFoto); FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); lblFactura.setIcon(null); }//GEN-LAST:event_btncancelarActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: JFileChooser fc = new JFileChooser(); int respuesta = fc.showOpenDialog(this); if (respuesta == JFileChooser.APPROVE_OPTION) { File archivoElegido = fc.getSelectedFile(); facturaField.setText(archivoElegido.getAbsolutePath()); // fotolbl.setIcon(new ImageIcon("C:/Users/Documentos/Desktop/HS/" + fotosField.getText())); ImageIcon fot = new ImageIcon(facturaField.getText()); Icon icono = new ImageIcon(fot.getImage().getScaledInstance(lblFactura.getWidth(), lblFactura.getHeight(), Image.SCALE_DEFAULT)); lblFactura.setIcon(icono); } }//GEN-LAST:event_jButton2ActionPerformed private int accion; private List<Factura> lista; private final FacturaControlador facturaControlador = new FacturaControlador(); // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btncancelar; private javax.swing.JButton btneliminar; private javax.swing.JButton btnguardar; private javax.swing.JButton btnmodificar; private javax.swing.JButton btnnuevo; private javax.swing.JTextField facturaField; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private com.toedter.calendar.JDateChooser jDateFecha; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel lblFactura; private javax.swing.JTextField nombreField; private javax.swing.JLabel nombreLabel; private javax.swing.JLabel nombreLabel1; private javax.swing.JPanel panelDatos; private javax.swing.JPanel panelFoto; private javax.swing.JPanel panelGuardar; private javax.swing.JPanel panelOpciones; private javax.swing.JTable tblFactura; private javax.swing.JTextField txtbuscar; // End of variables declaration//GEN-END:variables private void listar() { lista = this.facturaControlador.buscarTodos(); lista = ObservableCollections.observableList(lista); JTableBinding binding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, lista, tblFactura); BeanProperty bId = BeanProperty.create("id"); BeanProperty bNumero = BeanProperty.create("numeroFactura"); BeanProperty bFecha = BeanProperty.create("fecha"); BeanProperty bRuta = BeanProperty.create("ruta"); binding.addColumnBinding(bId).setColumnName("ID").setEditable(false); binding.addColumnBinding(bNumero).setColumnName("NUMERO").setEditable(false); binding.addColumnBinding(bFecha).setColumnName("FECHA").setEditable(false); binding.addColumnBinding(bRuta).setColumnName("RUTA").setEditable(false); binding.bind(); } }