Netbeans Issue

Hello all!

I have this problem with netbeans.. i Created a new project, and then created my application right.. So when i compile it does just fine, but when i try to run the App it wont do it.. :-/

I have pasted my code here cuz its much more easier to read, just go to the link:

http://pastebin.com/d19a1a45

Thanks!!

[351 byte] By [River_Platea] at [2007-11-27 10:45:31]
# 1

Post it here. Don't forget the code tags.

ejpa at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 2

and any error messages you get.

floundera at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 3

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

}

River_Platea at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 4

> The compiler is Saying:

> "Package org.Jdesktop.layout"

It would be saying more than that. Please copy and paste the entire error message. Do not paraphrase.

floundera at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 5

Package org.jdesktop.layout does not exist

:-/

The funny thing is that when i compile on Netbeans it compiles just fine.. But it doesn't run. When i compile on JCreator, gives me that error.. like in 40 lines.

River_Platea at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 6

Netbeans knows where that package is. JCreator doesn't know where it is. You will have to change the properties (or

whatever you do in JCreator. I haven't used it) so it can find the package.

floundera at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 7

Flounder:

Delete the main method, and try it on netbeans

I Added a main method there cuz Netbeans said that the class didn't have a main method.. but it compiled fine..

:-/

River_Platea at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 8

A. I don't have NetBeans or JCreator

B. It is not my job to copy your code, compile and debug it for you

floundera at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 9

ok pal i'm just asking for help... not trying to bother you..

Sorry

River_Platea at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...
# 10

And I told you the most likely cause of the problem in reply #6.

floundera at 2007-7-28 20:13:25 > top of Java-index,Java Essentials,New To Java...