Hello again! :-P
Well Here is the WHOLE code.. The compiler is Saying:
"Package org.Jdesktop.layout"
Here is the code:
/*
* Catalogo.java
*
* Created on July 16, 2007, 4:22 PM
*/
package segundo_parcial;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**
*
* @author Administrator
*/
public class Catalogo extends javax.swing.JPanel {
/** Creates new form Catalogo */
public Catalogo() {
initComponents();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
txtCodigo = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtPrecio = new javax.swing.JTextField();
Nuevo = new javax.swing.JCheckBox();
jScrollPane1 = new javax.swing.JScrollPane();
txtDescripcion = new javax.swing.JTextArea();
btnMostrar = new javax.swing.JButton();
btnAgregar = new javax.swing.JButton();
txtCantidad = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jLabel1.setText("Catalogo de Productos:");
jLabel2.setText("Codigo:");
jLabel3.setText("Cantidad:");
jLabel4.setText("Precio:");
txtPrecio.setEditable(false);
Nuevo.setText("Agregar Producto:");
Nuevo.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
Nuevo.setMargin(new java.awt.Insets(0, 0, 0, 0));
Nuevo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NuevoActionPerformed(evt);
}
});
txtDescripcion.setColumns(20);
txtDescripcion.setEditable(false);
txtDescripcion.setRows(5);
jScrollPane1.setViewportView(txtDescripcion);
btnMostrar.setText("Mostrar");
btnMostrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMostrarActionPerformed(evt);
}
});
btnAgregar.setText("Agregar");
btnAgregar.setEnabled(false);
btnAgregar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAgregarActionPerformed(evt);
}
});
txtCantidad.setEditable(false);
jLabel5.setText("Descripcion:");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel2)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel4)
.add(jLabel3))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(txtCodigo)
.add(txtCantidad)
.add(txtPrecio)
.add(Nuevo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 87, Short.MAX_VALUE)))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(7, 7, 7)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(btnMostrar)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(btnAgregar))
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 182, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel5)))
.add(25, 25, 25))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jLabel5))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(txtCodigo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(25, 25, 25)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(txtCantidad, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(20, 20, 20)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(txtPrecio, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(layout.createSequentialGroup()
.add(6, 6, 6)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(17, 17, 17)
.add(Nuevo))
.add(layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(btnAgregar)
.add(btnMostrar))))
.addContainerGap(89, Short.MAX_VALUE))
);
}// </editor-fold>
private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {
Connection conexion;
Statement sentencia;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (Exception e){
System.out.println("No se pudo conectar con el JDBC-ODBC");
return;
}
try{
conexion = DriverManager.getConnection("jdbc:odbc:con_sql","","" );
sentencia = conexion.createStatement();
String Precio = txtPrecio.getText();
String Cantidad = txtCantidad.getText();
String Descripcion = txtDescripcion.getText();
String Codigo = txtCodigo.getText();
sentencia.executeQuery("EXECUTE dbo.insertar @Codigo = '" + Codigo + "', @Precio = '" + Precio + "', @Descripcion = '" + Descripcion + "', @Existencia = '" + Cantidad + "';");
}
catch( Exception e ) {
System.out.println( e );
return;
}
}
private void btnMostrarActionPerformed(java.awt.event.ActionEvent evt) {
Connection conexion;
Statement sentencia;
ResultSet resultado;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (Exception e){
System.out.println("No se pudo conectar con el JDBC-ODBC");
return;
}
try{
conexion = DriverManager.getConnection("jdbc:odbc:con_sql","","" );
sentencia = conexion.createStatement();
String a = txtCodigo.getText();
resultado = sentencia.executeQuery("EXECUTE Muestra" + a);
while(resultado.next() ){
String Cantidad = resultado.getString("Existencia");
String Precio = resultado.getString("Precio");
String Descripcion = resultado.getString("Descripcion");
txtCantidad.setText(Cantidad);
txtPrecio.setText(Precio);
txtDescripcion.setText(Descripcion);
}
}
catch( Exception e ) {
System.out.println( e );
return;
}
}
private void NuevoActionPerformed(java.awt.event.ActionEvent evt) {
txtCantidad.setEditable(Nuevo.isSelected());
txtPrecio.setEditable(Nuevo.isSelected());
txtDescripcion.setEditable(Nuevo.isSelected());
btnAgregar.setEnabled(Nuevo.isSelected());
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Catalogo().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JCheckBox Nuevo;
private javax.swing.JButton btnAgregar;
private javax.swing.JButton btnMostrar;
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.JScrollPane jScrollPane1;
private javax.swing.JTextField txtCantidad;
private javax.swing.JTextField txtCodigo;
private javax.swing.JTextArea txtDescripcion;
private javax.swing.JTextField txtPrecio;
// End of variables declaration
}