Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/03/2010, 15:17
lince_36
 
Fecha de Ingreso: febrero-2010
Mensajes: 14
Antigüedad: 14 años, 9 meses
Puntos: 0
Respuesta: Mandar llamar a otra ventana por medio de un boton ¿como?. Mini aplicacion

Continuacion del codigo mas abajo:


Código:
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton4)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jButton1))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton3))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addComponent(jButton2)))
                .addContainerGap(56, Short.MAX_VALUE))
        );

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

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
    try{
        
        Class.forName("org.gjt.mm.mysql.Driver");
            conn=DriverManager.getConnection("jdbc:mysql://localhost/control_escolar","root","root");
            sentencia=conn.createStatement();
    
    
         res=sentencia.executeQuery("SELECT * FROM estudiantes");
         res.first();
         
         jTextField1.setText(res.getString(1));
         jTextField2.setText(res.getString(2));
         jTextField3.setText(res.getString(3));
         jTextField4.setText(res.getString(4));
         jTextField5.setText(res.getString(5));
         jTextField6.setText(res.getString(6));
         
    
    
    }
    catch(Exception e){
        JOptionPane.showMessageDialog(this,e.getMessage());
    
        
    }
}                                        

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         

    try{
    
    String Matricula=("0");
    String Nombre_Estudiante=jTextField2.getText();
     String Edad=jTextField3.getText();
     String Sexo=jTextField4.getText();
     String Telefono=jTextField5.getText();
     String Direccion=jTextField6.getText();
     
     jTextField1.setText("");
     jTextField2.setText("");
     jTextField3.setText("");
     jTextField4.setText("");
     jTextField5.setText("");
     jTextField6.setText("");
     

     sentencia.executeUpdate("INSERT INTO estudiantes VALUES  ('"+Matricula+"','"+Nombre_Estudiante+"','"+Edad+"','"+Sexo+"','"+Telefono+"','"+Direccion+"' )");
      }
    catch(Exception e){
       
        JOptionPane.showMessageDialog(this,e.getMessage());


    }

}                                        

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
 
    String Nombre_Estudiante=jTextField2.getText();
    try{
    
      sentencia.executeUpdate("DELETE from estudiantes where Nombre_Estudiante='"+Nombre_Estudiante+"'");
            
    

        
      }
    catch(Exception e){
       
        JOptionPane.showMessageDialog(this,e.getMessage());
      
  }
}                                        

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         

}                                        

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new alumnos().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    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.JLabel jLabel6;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    // End of variables declaration                   

    
}