Buenas necesito ayuda con un programa en java, el programa es basico sobre un inventario, en un jframe hize la parte principal del inventario para registrar los productos pero no se como poder guardarlos en una tabla que se ubica en otro jframe y que al dar click en el boton Mostrar Inventario de la ventana principal muestre todo lo que se halla guardado en el inventario en las tablas.
Esta es la ventana principal junto con su codigo package inventario;
import Atxy2k.CustomTextField.RestrictedTextField; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel;
public class Registro_de_datos extends javax.swing.JFrame {
public Registro_de_datos() {
//Personalizar el Jframe
initComponents();
setLocationRelativeTo(null);
setResizable(false);
setTitle("Registro de Productos al Inventario");
setIconImage(new ImageIcon(getClass().getResource("/Imagenes/empresa.png")).getImage());
//Poner fondo al JFrame
((JPanel)getContentPane()).setOpaque(false);
ImageIcon uno=new ImageIcon(this.getClass().getResource("/imagenes/fondo.jpg"));
JLabel fondo= new JLabel();
fondo.setIcon(uno);
getLayeredPane().add(fondo,JLayeredPane.FRAME_CONTENT_LAYER);
fondo.setBounds(0,0,uno.getIconWidth(),uno.getIconHeight());
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
Producto = new javax.swing.JLabel();
Marca = new javax.swing.JLabel();
Cantidad = new javax.swing.JLabel();
Distribuidor = new javax.swing.JLabel();
CodProducto = new javax.swing.JLabel();
FechaIngreso = new javax.swing.JLabel();
Precio = new javax.swing.JLabel();
ProductoCampo = new javax.swing.JTextField();
MarcaCampo = new javax.swing.JTextField();
CantidadCampo = new javax.swing.JTextField();
CodigoCampo = new javax.swing.JTextField();
FechaCampo = new javax.swing.JTextField();
DistribuidorCampo = new javax.swing.JTextField();
PrecioCampo = new javax.swing.JTextField();
ButtonGuardar = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Inventario - Registro de Datos");
setBackground(new java.awt.Color(151, 169, 245));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jLabel1.setBackground(new java.awt.Color(204, 204, 255));
jLabel1.setFont(new java.awt.Font("Yahoo", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(204, 0, 51));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("INGRESAR PRODUCTOS AL INVENTARIO");
jLabel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
Producto.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
Producto.setText("Producto:");
Marca.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
Marca.setText("Marca:");
Cantidad.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
Cantidad.setText("Cantidad:");
Distribuidor.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
Distribuidor.setText("Distribuidor:");
CodProducto.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
CodProducto.setText("Codigo Producto:");
FechaIngreso.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
FechaIngreso.setText("Fecha de Ingreso:");
Precio.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
Precio.setText("Precio Bs.F:");
ProductoCampo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ProductoCampoActionPerformed(evt);
}
});
ProductoCampo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
ProductoCampoKeyTyped(evt);
}
});
MarcaCampo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MarcaCampoActionPerformed(evt);
}
});
MarcaCampo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
MarcaCampoKeyTyped(evt);
}
});
CantidadCampo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
CantidadCampoKeyTyped(evt);
}
});
CodigoCampo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CodigoCampoActionPerformed(evt);
}
});
CodigoCampo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
CodigoCampoKeyTyped(evt);
}
});
FechaCampo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
FechaCampoKeyTyped(evt);
}
});
DistribuidorCampo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
DistribuidorCampoKeyTyped(evt);
}
});
PrecioCampo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
PrecioCampoKeyTyped(evt);
}
});
ButtonGuardar.setBackground(new java.awt.Color(153, 153, 255));
ButtonGuardar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
ButtonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/disquete.png"))); // NOI18N
ButtonGuardar.setText("Guardar");
ButtonGuardar.setToolTipText("");
ButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ButtonGuardarActionPerformed(evt);
}
});
jButton1.setBackground(new java.awt.Color(153, 153, 255));
jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/salir.png"))); // NOI18N
jButton1.setText("Salir");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setBackground(new java.awt.Color(153, 153, 255));
jButton2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/menu.png"))); // NOI18N
jButton2.setText("Mostrar Inventario");
jButton2.setToolTipText("");
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()
.addGap(103, 103, 103)
.addComponent(ButtonGuardar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(87, 87, 87))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jButton2)
.addGap(221, 221, 221))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(Producto)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ProductoCampo, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(36, 36, 36)
.addComponent(Marca)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(MarcaCampo, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(Cantidad)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(CantidadCampo, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(CodProducto)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(CodigoCampo, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(FechaIngreso)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(FechaCampo, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(Distribuidor)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(DistribuidorCampo, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(Precio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(PrecioCampo, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(33, 33, 33))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 541, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(58, 58, 58)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Producto)
.addComponent(Marca)
.addComponent(ProductoCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(MarcaCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Cantidad)
.addComponent(CantidadCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(CodProducto)
.addComponent(CodigoCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(FechaIngreso)
.addComponent(FechaCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Precio)
.addComponent(Distribuidor)
.addComponent(DistribuidorCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(PrecioCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(54, 54, 54)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ButtonGuardar)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void ProductoCampoActionPerformed(java.awt.event.ActionEvent evt) {
}
private void MarcaCampoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void CodigoCampoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void ProductoCampoKeyTyped(java.awt.event.KeyEvent evt) {
char validar=evt.getKeyChar();
if(Character.isDigit(validar)){
getToolkit().beep();
evt.consume();
}
}
private void CodigoCampoKeyTyped(java.awt.event.KeyEvent evt) {
char validar=evt.getKeyChar();
if (Character.isLetter(validar)){
getToolkit().beep();
evt.consume();
}
}
private void CantidadCampoKeyTyped(java.awt.event.KeyEvent evt) {
char validar=evt.getKeyChar();
if (Character.isLetter(validar)){
getToolkit().beep();
evt.consume();
}
}
private void PrecioCampoKeyTyped(java.awt.event.KeyEvent evt) {
char validar=evt.getKeyChar();
if (Character.isLetter(validar)){
getToolkit().beep();
evt.consume();
}
}
private void MarcaCampoKeyTyped(java.awt.event.KeyEvent evt) {
char validar=evt.getKeyChar();
if(Character.isDigit(validar)){
getToolkit().beep();
evt.consume();
}
}
private void DistribuidorCampoKeyTyped(java.awt.event.KeyEvent evt) {
char validar=evt.getKeyChar();
if(Character.isDigit(validar)){
getToolkit().beep();
evt.consume();
}
}
private void FechaCampoKeyTyped(java.awt.event.KeyEvent evt) {
char validar=evt.getKeyChar();
if (Character.isLetter(validar)){
getToolkit().beep();
evt.consume();
}
}
private void ButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {
}
public static void main(String args[]) {
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Registro_de_datos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Registro_de_datos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Registro_de_datos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Registro_de_datos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Registro_de_datos().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton ButtonGuardar;
private javax.swing.JLabel Cantidad;
private javax.swing.JTextField CantidadCampo;
private javax.swing.JLabel CodProducto;
private javax.swing.JTextField CodigoCampo;
private javax.swing.JLabel Distribuidor;
private javax.swing.JTextField DistribuidorCampo;
private javax.swing.JTextField FechaCampo;
private javax.swing.JLabel FechaIngreso;
private javax.swing.JLabel Marca;
private javax.swing.JTextField MarcaCampo;
private javax.swing.JLabel Precio;
private javax.swing.JTextField PrecioCampo;
private javax.swing.JLabel Producto;
private javax.swing.JTextField ProductoCampo;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
Esta es la segunda ventana package inventario;
import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.table.DefaultTableModel;
public class Inventario extends javax.swing.JFrame { DefaultTableModel modelo;
public Inventario() {
initComponents();
setLocationRelativeTo(null);
setResizable(false);
setTitle("Inventario");
setIconImage(new ImageIcon(getClass().getResource("/Imagenes/empresa.png")).getImage());
//Poner fondo al JFrame
((JPanel)getContentPane()).setOpaque(false);
ImageIcon uno=new ImageIcon(this.getClass().getResource("/imagenes/fondo.jpg"));
JLabel fondo= new JLabel();
fondo.setIcon(uno);
getLayeredPane().add(fondo,JLayeredPane.FRAME_CONTENT_LAYER);
fondo.setBounds(0,0,uno.getIconWidth(),uno.getIconHeight());
//TABLA
modelo = new DefaultTableModel();
Tabla.setModel(modelo);
modelo.addColumn("Producto");
modelo.addColumn("Marca");
modelo.addColumn("Cantidad");
modelo.addColumn("Codigo Producto");
modelo.addColumn("Fecha Ingreso:");
modelo.addColumn("Distribuidor");
modelo.addColumn("Precio Bs");
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
Tabla = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setBackground(new java.awt.Color(204, 204, 255));
jLabel1.setFont(new java.awt.Font("Yahoo", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(204, 0, 51));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("INVENTARIO");
jLabel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton1.setBackground(new java.awt.Color(153, 153, 255));
jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/eliminar.png"))); // NOI18N
jButton1.setText("Eliminar");
jButton1.setToolTipText("");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setBackground(new java.awt.Color(153, 153, 255));
jButton2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/salir.png"))); // NOI18N
jButton2.setText("Salir");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
Tabla.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"
}
));
jScrollPane1.setViewportView(Tabla);
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()
.addGap(0, 23, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 539, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18))
.addGroup(layout.createSequentialGroup()
.addGap(102, 102, 102)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(94, 94, 94))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 393, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(79, 79, 79))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(30, 30, 30)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 121, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap())
);
pack();
}// </editor-fold>
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int fila = Tabla.getSelectedRow();
if(fila != -1){
modelo.removeRow(fila);
}else{
JOptionPane.showMessageDialog(this,"Debe seleccionar un producto");
}
}
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Inventario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Inventario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Inventario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Inventario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Inventario().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTable Tabla;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration
}