SlideShare a Scribd company logo
Java - Boton Eliminar Java NetBeans-Mysql




                                                   <<>>
Filtrado por todos los mensajes



            arbol
Vistas:

Boton Eliminar Java NetBeans-Mysql
Didier Francisco Orjuela Lopez (20/10/2012 07:32:02)
                                                                                             668 visitas
                                                                                           4 respuestas

 Boton Eliminar Java NetBeans-Mysql
omar (05/01/2013 01:27:03)

Boton Eliminar Java NetBeans-Mysql
Daniel Efrén (05/01/2013 14:25:32)

 <font><font>Boton ELIMINAR Java NetBeans Mysql</font></font>
omar (10/01/2013 18:11:36)

 <font><font>Boton ELIMINAR Java NetBeans Mysql</font></font>
omar (27/01/2013 02:29:31)



0         Asunto: Boton Eliminar Java NetBeans-Mysql
           Autor: Didier Francisco Orjuela Lopez (2 intervenciones)
         Fecha: 20/10/2012 07:32:02
Buenas Noches
Necesito un favor urgente, este es
Tengo esta interfaz http://sdrv.ms/TErsgi
El programa consta de una conexion entre Java Netbeans y Mysql
tengo 5 campos en las tabla contrato de mysql ya tengo el boyonactualizar y este los muestra en la
tabla.
Necesito saber el codigo para poder eliminar por numero contrato (numero contrato tiene
auto:incremento en mysql)
Tambien poder ordenar por numero contrato y el boton buscar les agardeceria mucho cualquier
tipo de ayuda
ste es el codigo que tengo:
Cree una clase conectar esta es donde llamo la base de datos esta se llama icasaf dentro de esta esta la
tabla contrato
importjava.sql.Connection;
importjava.sql.DriverManager;
importjavax.swing.*;
importjava.sql.*;




/**
 *
 * @authorUser
 */
publicclass conectar {




Connectionconect = null;




public Connectionconexion()
{
    try {

        Class.forName("org.gjt.mm.mysql.Driver");
        conect= DriverManager.getConnection("jdbc:mysql://localhost/icasaf", "root","12345" );
        //JOptionPane.showMessageDialog(null, "Conectado");


         }
        catch (Exception e) {
          JOptionPane.showMessageDialog(null, "Error"+e);



}
 returnconect;



    }




}




Este es el codigo que tengo
importjava.sql.*;
importjava.util.logging.Level;
importjava.util.logging.Logger;
importjavax.swing.*;
importjavax.swing.table.DefaultTableModel;
/**
 *
 * @authorUser
 */
publicclass Contrato extends javax.swing.JFrame {
DefaultTableModel model;
    /**
     * Creates new form Contrato
     */
void cargar(String valor) {




String titulos [] = {"Numero", "Tipo", "Fecha", "T. Pago", "Codigo Cliente"};
String [] registros = new String [5];
String sql = "select*from contrato where N_CONT LIKE '%" +valor+"%'";
model = new DefaultTableModel(null, titulos);
conectar cc=new conectar();
Connection cn = cc.conexion();
try {
Statement st = cn.createStatement();
ResultSet rs = st.executeQuery(sql);




while (rs.next()){
registros[0]=rs.getString("N_CONT");
registros[1]=rs.getString("TIP_CONT");
registros[2]=rs.getString("FECH_CONT");
registros[3]=rs.getString("TIPPAGO_CONT");
registros[4]=rs.getString("COD_CLIE");




model.addRow(registros);




}
t_datos.setModel(model);




} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex);




}
}
    public Contrato() {
       initComponents();
      limpiar();
      bloquear();
      cargar("");
    }
     void limpiar(){

      T1.setText("");
      T2.setText("");
T3.setText("");
       T4.setText("");

          }
   void bloquear() {

       T1.setEnabled(false);
       T2.setEnabled(false);
       T3.setEnabled(false);
       T4.setEnabled(false);
       jButton1.setEnabled(true);
       b2.setEnabled(false);
       jButton3.setEnabled(false);
   }

void desbloquear() {
      T1.setEnabled(true);
      T2.setEnabled(true);
      T3.setEnabled(true);
      T4.setEnabled(true);
      jButton1.setEnabled(false);
      b2.setEnabled(true);
      jButton3.setEnabled(true);
}
  /**
   * 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">
  private void initComponents() {




       jPanel1 = new javax.swing.JPanel();
       jLabel1 = new javax.swing.JLabel();
       jLabel2 = new javax.swing.JLabel();
       jLabel3 = new javax.swing.JLabel();
       jLabel4 = new javax.swing.JLabel();
       jLabel5 = new javax.swing.JLabel();
       T1 = new javax.swing.JTextField();
       T2 = new javax.swing.JTextField();
       T3 = new javax.swing.JTextField();
       T4 = new javax.swing.JTextField();
       jButton1 = new javax.swing.JButton();
       b2 = new javax.swing.JButton();
       jButton3 = new javax.swing.JButton();
       jButton4 = new javax.swing.JButton();
       jScrollPane1 = new javax.swing.JScrollPane();
       t_datos = new javax.swing.JTable();
       jLabel6 = new javax.swing.JLabel();
       jLabel7 = new javax.swing.JLabel();
       jLabel8 = new javax.swing.JLabel();
       aux = new javax.swing.JTextField();
       jLabel9 = new javax.swing.JLabel();
       jTextField6 = new javax.swing.JTextField();
       jButton5 = new javax.swing.JButton();
       jRadioButton1 = new javax.swing.JRadioButton();
       jRadioButton2 = new javax.swing.JRadioButton();
       jButton2 = new javax.swing.JButton();
       jLabel10 = new javax.swing.JLabel();
       jComboBox1 = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);




     jPanel1.setBackground(new java.awt.Color(51, 51, 51));
     jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Contrato",
javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new
java.awt.Font("Comic Sans MS", 1, 18), new java.awt.Color(204, 204, 204))); // NOI18N
     jPanel1.setForeground(new java.awt.Color(204, 204, 204));




    jLabel1.setBackground(new java.awt.Color(51, 51, 51));
    jLabel1.setText("Numero:");




    jLabel2.setBackground(new java.awt.Color(51, 51, 51));
    jLabel2.setText("Tipo:");




    jLabel3.setBackground(new java.awt.Color(51, 51, 51));
    jLabel3.setText("Fecha:");




    jLabel4.setBackground(new java.awt.Color(51, 51, 51));
    jLabel4.setText("Tipo De Pago:");




    jLabel5.setBackground(new java.awt.Color(51, 51, 51));
    jLabel5.setText("Codigo Cliente:");




    T1.setBackground(new java.awt.Color(51, 51, 51));
    T1.setForeground(new java.awt.Color(204, 204, 204));
    T1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          T1ActionPerformed(evt);
        }
    });




    T2.setBackground(new java.awt.Color(51, 51, 51));
    T2.setForeground(new java.awt.Color(204, 204, 204));
    T2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          T2ActionPerformed(evt);
        }
    });
T3.setBackground(new java.awt.Color(51, 51, 51));
    T3.setForeground(new java.awt.Color(204, 204, 204));
    T3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          T3ActionPerformed(evt);
        }
    });




    T4.setBackground(new java.awt.Color(51, 51, 51));
    T4.setForeground(new java.awt.Color(204, 204, 204));
    T4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          T4ActionPerformed(evt);
        }
    });




    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Inmocasaf/Agre.png"))); //
NOI18N
    jButton1.setText("Nuevo");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          jButton1ActionPerformed(evt);
        }
    });




    b2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Inmocasaf/Guar.png"))); // NOI18N
    b2.setText("Agregar");
    b2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          b2ActionPerformed(evt);
        }
    });




    jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Inmocasaf/Cancelar.png"))); //
NOI18N
    jButton3.setText("Cancelar");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          jButton3ActionPerformed(evt);
        }
    });




    jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Inmocasaf/Candado.png"))); //
NOI18N
    jButton4.setText("Salir");
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          jButton4ActionPerformed(evt);
        }
    });
t_datos.setModel(new javax.swing.table.DefaultTableModel(
       new Object [][] {
          {},
          {},
          {},
          {}
       },
       new String [] {




        }
    ));
    jScrollPane1.setViewportView(t_datos);




    jLabel6.setForeground(new java.awt.Color(0, 153, 153));
    jLabel6.setText("Auto_Incremento");




    jLabel7.setForeground(new java.awt.Color(0, 102, 102));

jLabel7.setText("_______________________________________________________________________
___________________");




    jLabel8.setForeground(new java.awt.Color(0, 102, 102));
    jLabel8.setText("Buscar Por Numero Contrato:");




    aux.setBackground(new java.awt.Color(0, 0, 0));
    aux.setForeground(new java.awt.Color(0, 102, 102));
    aux.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
          auxKeyReleased(evt);
        }
    });




    jLabel9.setForeground(new java.awt.Color(0, 102, 102));
    jLabel9.setText("Eliminar Por Numero Contaro:");




    jTextField6.setBackground(new java.awt.Color(0, 0, 0));
    jTextField6.setForeground(new java.awt.Color(0, 102, 102));




    jButton5.setText("Eliminar");
    jButton5.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
          }
    });




    jRadioButton1.setBackground(new java.awt.Color(51, 51, 51));
    jRadioButton1.setForeground(new java.awt.Color(204, 204, 204));
    jRadioButton1.setText("Inicio");
    jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          jRadioButton1ActionPerformed(evt);
        }
    });




    jRadioButton2.setBackground(new java.awt.Color(51, 51, 51));
    jRadioButton2.setForeground(new java.awt.Color(204, 204, 204));
    jRadioButton2.setText("Opciones Mysql.");
    jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          jRadioButton2ActionPerformed(evt);
        }
    });




    jButton2.setText("Buscar");




    jLabel10.setText("Ordenar POr:");




    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tipo Contrato",
"Numero de Contrato", "Codigo Cliente" }));




    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
       jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
       .addGroup(jPanel1Layout.createSequentialGroup()
          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                         .addComponent(jLabel3)
                         .addComponent(jLabel4)
                         .addComponent(jLabel1)
                         .addComponent(jLabel2)
.addComponent(jLabel5))
                       .addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                           .addComponent(T2)
                           .addComponent(T1)
                           .addComponent(T4)
                           .addComponent(T3)
                           .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 236,
Short.MAX_VALUE)))
                     .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jRadioButton1)
                        .addGap(18, 18, 18)
                        .addComponent(jRadioButton2)))
                  .addGap(47, 47, 47)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                     .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE)
                     .addComponent(b2, javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE)
                     .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE)
                     .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addComponent(jScrollPane1)
                .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
            .addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createSequentialGroup()
                       .addComponent(jLabel9)
                       .addGap(18, 18, 18)
                       .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 226,
javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                       .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 150,
javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                       .addComponent(aux)))
                 .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel10)
                    .addGap(70, 70, 70)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 176,
javax.swing.GroupLayout.PREFERRED_SIZE)))
              .addGap(29, 29, 29)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                  .addGroup(jPanel1Layout.createSequentialGroup()
                     .addComponent(jButton2)
                     .addGap(0, 0, Short.MAX_VALUE)))))
           .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
     );
     jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
           .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
              .addComponent(jLabel8)
              .addComponent(aux, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2))
          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(30, 30, 30))
             .addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel9)
                .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                 .addGroup(jPanel1Layout.createSequentialGroup()
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel10)
                    .addGap(18, 18, 18))
                 .addGroup(jPanel1Layout.createSequentialGroup()
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
          .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 160,
javax.swing.GroupLayout.PREFERRED_SIZE)
          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
          .addComponent(jLabel7)
          .addGap(3, 3, 3)
          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
             .addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel1)
                .addComponent(jLabel6))
             .addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                 .addComponent(jLabel2)
                 .addComponent(T1, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                 .addComponent(jLabel3)
                 .addComponent(T2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                 .addComponent(jLabel4)
                 .addComponent(T3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                 .addComponent(jLabel5)
                 .addComponent(T4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jRadioButton1)
.addComponent(jRadioButton2)))
             .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(b2, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE)))
          .addContainerGap())
     );




     javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
     getContentPane().setLayout(layout);
     layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
           .addContainerGap()
           .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
           .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
     );
     layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
     );




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




   private void T1ActionPerformed(java.awt.event.ActionEvent evt) {
T1.transferFocus();
// TODO add your handling code here:
   }




  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
desbloquear();
T1.requestFocus();      // TODO add your handling code here:
  }




  private void T2ActionPerformed(java.awt.event.ActionEvent evt) {
T2.transferFocus();    // TODO add your handling code here:
  }
private void T3ActionPerformed(java.awt.event.ActionEvent evt) {
T3.transferFocus();    // TODO add your handling code here:
  }




  private void T4ActionPerformed(java.awt.event.ActionEvent evt) {
T4.transferFocus();    // TODO add your handling code here:
  }




   private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
bloquear();
// TODO add your handling code here:
   }




   private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
// TODO add your handling code here:
   }




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

new Inicio().setVisible(true);
// TODO add your handling code here:
   }




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

 new Javamysql().setVisible(true);     // TODO add your handling code here:
  }




  private void b2ActionPerformed(java.awt.event.ActionEvent evt) {
  conectar cc = new conectar();
Connection cn = cc.conexion();




String TIP_CONT,FECH_CONT, TIPPAGO_CONT, COD_CLIE;
String sql="";
TIP_CONT = T1.getText();
FECH_CONT = T2.getText();
TIPPAGO_CONT = T3.getText();
COD_CLIE = T4.getText();




sql = "INSERT INTO contrato (`Tip_cont`,`Fech_cont`,`Tippago_cont`,`Cod_clie`) VALUES (?,?,?,? )";
try {
PreparedStatement pst = cn.prepareStatement(sql);
pst.setString(1, TIP_CONT);
pst.setString(2, FECH_CONT);
pst.setString(3, TIPPAGO_CONT);
pst.setString(4, COD_CLIE);




int a = pst.executeUpdate();
if (a>0){
JOptionPane.showMessageDialog(null ,"Registro Guardado Con exito");




bloquear();
cargar("");
limpiar();




}
} catch (SQLException ex) {
Logger.getLogger(Inmueble.class.getName()).log(Level.SEVERE, null, ex);
}
// TODO addyourhandlingcodehere:
  }




   privatevoidauxKeyReleased(java.awt.event.KeyEventevt) {
  cargar(aux.getText());   // TODO addyourhandlingcodehere:
   }
http://www.lawebdelprogramador.com/img/btn_previsualizar.png

En verdad agradecería toto tipo de ayuda

More Related Content

DOCX
Exercícios Netbeans - Vera Cymbron
DOCX
Ip project work test your knowledge
PDF
#JavaFX.forReal() - ElsassJUG
PDF
Construire une application JavaFX 8 avec gradle
PDF
Advanced Java Practical File
PPTX
JavaScript Proven Practises
PDF
Magic methods
DOCX
Wwe Management System
Exercícios Netbeans - Vera Cymbron
Ip project work test your knowledge
#JavaFX.forReal() - ElsassJUG
Construire une application JavaFX 8 avec gradle
Advanced Java Practical File
JavaScript Proven Practises
Magic methods
Wwe Management System

What's hot (20)

PDF
Java 7 LavaJUG
PDF
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
PDF
ESNext for humans - LvivJS 16 August 2014
PPTX
The uniform interface is 42
PPTX
PHP 5 Magic Methods
DOCX
Java practical
PDF
Important java programs(collection+file)
PDF
Software Testing - Invited Lecture at UNSW Sydney
PPTX
Unit Testing with Foq
DOCX
Advance Java Programs skeleton
PDF
Sam wd programs
KEY
SOLID Principles
PDF
Conf soat tests_unitaires_Mockito_jUnit_170113
DOC
Ad java prac sol set
PPT
2012 JDays Bad Tests Good Tests
PDF
Java_practical_handbook
DOCX
Ejemplo radio
PDF
Practical JavaScript Programming - Session 4/8
DOC
Ejemplos Interfaces Usuario 3
DOC
Create a Customized GMF DnD Framework
Java 7 LavaJUG
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
ESNext for humans - LvivJS 16 August 2014
The uniform interface is 42
PHP 5 Magic Methods
Java practical
Important java programs(collection+file)
Software Testing - Invited Lecture at UNSW Sydney
Unit Testing with Foq
Advance Java Programs skeleton
Sam wd programs
SOLID Principles
Conf soat tests_unitaires_Mockito_jUnit_170113
Ad java prac sol set
2012 JDays Bad Tests Good Tests
Java_practical_handbook
Ejemplo radio
Practical JavaScript Programming - Session 4/8
Ejemplos Interfaces Usuario 3
Create a Customized GMF DnD Framework
Ad

Similar to Java (20)

DOCX
Registro de venta
TXT
Interfaz Grafica En Java
PDF
PLEASE HELP ME !!IT IS Due Tonight ;(!i have to submit it before.pdf
DOCX
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
DOCX
Library management system
PPTX
swing_compo.pptxsfdsfffdfdfdfdgwrwrwwtry
DOCX
Balance de ingresos y egresos diarios de una persona
PPT
Swing basics
PPT
Chapter 5 GUI for introduction of java and gui .ppt
DOCX
Student management system
PDF
Hafitz_Rizki 201343500823 JMenuBar_JavaMsAccess_JavaGrade
PDF
Programa simulacion de ventas de aeropuerto
PDF
Formulario en java
RTF
Easy Button
PDF
MaintainStaffTable
DOCX
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
PPTX
PDF
A new class will be added to the startup package to start up the eve.pdf
DOCX
PDF
package buttongui; import static com.sun.deploy.config.JREInf.pdf
Registro de venta
Interfaz Grafica En Java
PLEASE HELP ME !!IT IS Due Tonight ;(!i have to submit it before.pdf
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
Library management system
swing_compo.pptxsfdsfffdfdfdfdgwrwrwwtry
Balance de ingresos y egresos diarios de una persona
Swing basics
Chapter 5 GUI for introduction of java and gui .ppt
Student management system
Hafitz_Rizki 201343500823 JMenuBar_JavaMsAccess_JavaGrade
Programa simulacion de ventas de aeropuerto
Formulario en java
Easy Button
MaintainStaffTable
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
A new class will be added to the startup package to start up the eve.pdf
package buttongui; import static com.sun.deploy.config.JREInf.pdf
Ad

Java

  • 1. Java - Boton Eliminar Java NetBeans-Mysql <<>> Filtrado por todos los mensajes arbol Vistas: Boton Eliminar Java NetBeans-Mysql Didier Francisco Orjuela Lopez (20/10/2012 07:32:02) 668 visitas 4 respuestas Boton Eliminar Java NetBeans-Mysql omar (05/01/2013 01:27:03) Boton Eliminar Java NetBeans-Mysql Daniel Efrén (05/01/2013 14:25:32) <font><font>Boton ELIMINAR Java NetBeans Mysql</font></font> omar (10/01/2013 18:11:36) <font><font>Boton ELIMINAR Java NetBeans Mysql</font></font> omar (27/01/2013 02:29:31) 0 Asunto: Boton Eliminar Java NetBeans-Mysql Autor: Didier Francisco Orjuela Lopez (2 intervenciones) Fecha: 20/10/2012 07:32:02 Buenas Noches Necesito un favor urgente, este es Tengo esta interfaz http://sdrv.ms/TErsgi El programa consta de una conexion entre Java Netbeans y Mysql tengo 5 campos en las tabla contrato de mysql ya tengo el boyonactualizar y este los muestra en la tabla. Necesito saber el codigo para poder eliminar por numero contrato (numero contrato tiene auto:incremento en mysql) Tambien poder ordenar por numero contrato y el boton buscar les agardeceria mucho cualquier tipo de ayuda ste es el codigo que tengo: Cree una clase conectar esta es donde llamo la base de datos esta se llama icasaf dentro de esta esta la
  • 2. tabla contrato importjava.sql.Connection; importjava.sql.DriverManager; importjavax.swing.*; importjava.sql.*; /** * * @authorUser */ publicclass conectar { Connectionconect = null; public Connectionconexion() { try { Class.forName("org.gjt.mm.mysql.Driver"); conect= DriverManager.getConnection("jdbc:mysql://localhost/icasaf", "root","12345" ); //JOptionPane.showMessageDialog(null, "Conectado"); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error"+e); } returnconect; } } Este es el codigo que tengo importjava.sql.*; importjava.util.logging.Level; importjava.util.logging.Logger; importjavax.swing.*;
  • 3. importjavax.swing.table.DefaultTableModel; /** * * @authorUser */ publicclass Contrato extends javax.swing.JFrame { DefaultTableModel model; /** * Creates new form Contrato */ void cargar(String valor) { String titulos [] = {"Numero", "Tipo", "Fecha", "T. Pago", "Codigo Cliente"}; String [] registros = new String [5]; String sql = "select*from contrato where N_CONT LIKE '%" +valor+"%'"; model = new DefaultTableModel(null, titulos); conectar cc=new conectar(); Connection cn = cc.conexion(); try { Statement st = cn.createStatement(); ResultSet rs = st.executeQuery(sql); while (rs.next()){ registros[0]=rs.getString("N_CONT"); registros[1]=rs.getString("TIP_CONT"); registros[2]=rs.getString("FECH_CONT"); registros[3]=rs.getString("TIPPAGO_CONT"); registros[4]=rs.getString("COD_CLIE"); model.addRow(registros); } t_datos.setModel(model); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } } public Contrato() { initComponents(); limpiar(); bloquear(); cargar(""); } void limpiar(){ T1.setText(""); T2.setText("");
  • 4. T3.setText(""); T4.setText(""); } void bloquear() { T1.setEnabled(false); T2.setEnabled(false); T3.setEnabled(false); T4.setEnabled(false); jButton1.setEnabled(true); b2.setEnabled(false); jButton3.setEnabled(false); } void desbloquear() { T1.setEnabled(true); T2.setEnabled(true); T3.setEnabled(true); T4.setEnabled(true); jButton1.setEnabled(false); b2.setEnabled(true); jButton3.setEnabled(true); } /** * 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"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); T1 = new javax.swing.JTextField(); T2 = new javax.swing.JTextField(); T3 = new javax.swing.JTextField(); T4 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); b2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); t_datos = new javax.swing.JTable(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); aux = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); jTextField6 = new javax.swing.JTextField(); jButton5 = new javax.swing.JButton(); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton2 = new javax.swing.JRadioButton(); jButton2 = new javax.swing.JButton(); jLabel10 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox();
  • 5. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setBackground(new java.awt.Color(51, 51, 51)); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Contrato", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Comic Sans MS", 1, 18), new java.awt.Color(204, 204, 204))); // NOI18N jPanel1.setForeground(new java.awt.Color(204, 204, 204)); jLabel1.setBackground(new java.awt.Color(51, 51, 51)); jLabel1.setText("Numero:"); jLabel2.setBackground(new java.awt.Color(51, 51, 51)); jLabel2.setText("Tipo:"); jLabel3.setBackground(new java.awt.Color(51, 51, 51)); jLabel3.setText("Fecha:"); jLabel4.setBackground(new java.awt.Color(51, 51, 51)); jLabel4.setText("Tipo De Pago:"); jLabel5.setBackground(new java.awt.Color(51, 51, 51)); jLabel5.setText("Codigo Cliente:"); T1.setBackground(new java.awt.Color(51, 51, 51)); T1.setForeground(new java.awt.Color(204, 204, 204)); T1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { T1ActionPerformed(evt); } }); T2.setBackground(new java.awt.Color(51, 51, 51)); T2.setForeground(new java.awt.Color(204, 204, 204)); T2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { T2ActionPerformed(evt); } });
  • 6. T3.setBackground(new java.awt.Color(51, 51, 51)); T3.setForeground(new java.awt.Color(204, 204, 204)); T3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { T3ActionPerformed(evt); } }); T4.setBackground(new java.awt.Color(51, 51, 51)); T4.setForeground(new java.awt.Color(204, 204, 204)); T4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { T4ActionPerformed(evt); } }); jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Inmocasaf/Agre.png"))); // NOI18N jButton1.setText("Nuevo"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); b2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Inmocasaf/Guar.png"))); // NOI18N b2.setText("Agregar"); b2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { b2ActionPerformed(evt); } }); jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Inmocasaf/Cancelar.png"))); // NOI18N jButton3.setText("Cancelar"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Inmocasaf/Candado.png"))); // NOI18N jButton4.setText("Salir"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } });
  • 7. t_datos.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {}, {}, {}, {} }, new String [] { } )); jScrollPane1.setViewportView(t_datos); jLabel6.setForeground(new java.awt.Color(0, 153, 153)); jLabel6.setText("Auto_Incremento"); jLabel7.setForeground(new java.awt.Color(0, 102, 102)); jLabel7.setText("_______________________________________________________________________ ___________________"); jLabel8.setForeground(new java.awt.Color(0, 102, 102)); jLabel8.setText("Buscar Por Numero Contrato:"); aux.setBackground(new java.awt.Color(0, 0, 0)); aux.setForeground(new java.awt.Color(0, 102, 102)); aux.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { auxKeyReleased(evt); } }); jLabel9.setForeground(new java.awt.Color(0, 102, 102)); jLabel9.setText("Eliminar Por Numero Contaro:"); jTextField6.setBackground(new java.awt.Color(0, 0, 0)); jTextField6.setForeground(new java.awt.Color(0, 102, 102)); jButton5.setText("Eliminar"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) {
  • 8. jButton5ActionPerformed(evt); } }); jRadioButton1.setBackground(new java.awt.Color(51, 51, 51)); jRadioButton1.setForeground(new java.awt.Color(204, 204, 204)); jRadioButton1.setText("Inicio"); jRadioButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton1ActionPerformed(evt); } }); jRadioButton2.setBackground(new java.awt.Color(51, 51, 51)); jRadioButton2.setForeground(new java.awt.Color(204, 204, 204)); jRadioButton2.setText("Opciones Mysql."); jRadioButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton2ActionPerformed(evt); } }); jButton2.setText("Buscar"); jLabel10.setText("Ordenar POr:"); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tipo Contrato", "Numero de Contrato", "Codigo Cliente" })); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jLabel1) .addComponent(jLabel2)
  • 9. .addComponent(jLabel5)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(T2) .addComponent(T1) .addComponent(T4) .addComponent(T3) .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jRadioButton1) .addGap(18, 18, 18) .addComponent(jRadioButton2))) .addGap(47, 47, 47) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(b2, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jScrollPane1) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addComponent(jLabel9) .addGap(18, 18, 18) .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(aux))) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel10) .addGap(70, 70, 70) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(29, 29, 29) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton2) .addGap(0, 0, Short.MAX_VALUE))))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel8) .addComponent(aux, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  • 10. .addComponent(jButton2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(30, 30, 30)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9) .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel10) .addGap(18, 18, 18)) .addGroup(jPanel1Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel7) .addGap(3, 3, 3) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jLabel6)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(T1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(T2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(T3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(T4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jRadioButton1)
  • 11. .addComponent(jRadioButton2))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(b2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ); pack(); }// </editor-fold> private void T1ActionPerformed(java.awt.event.ActionEvent evt) { T1.transferFocus(); // TODO add your handling code here: } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { desbloquear(); T1.requestFocus(); // TODO add your handling code here: } private void T2ActionPerformed(java.awt.event.ActionEvent evt) { T2.transferFocus(); // TODO add your handling code here: }
  • 12. private void T3ActionPerformed(java.awt.event.ActionEvent evt) { T3.transferFocus(); // TODO add your handling code here: } private void T4ActionPerformed(java.awt.event.ActionEvent evt) { T4.transferFocus(); // TODO add your handling code here: } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { bloquear(); // TODO add your handling code here: } private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { this.dispose(); // TODO add your handling code here: } private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) { new Inicio().setVisible(true); // TODO add your handling code here: } private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) { new Javamysql().setVisible(true); // TODO add your handling code here: } private void b2ActionPerformed(java.awt.event.ActionEvent evt) { conectar cc = new conectar(); Connection cn = cc.conexion(); String TIP_CONT,FECH_CONT, TIPPAGO_CONT, COD_CLIE; String sql="";
  • 13. TIP_CONT = T1.getText(); FECH_CONT = T2.getText(); TIPPAGO_CONT = T3.getText(); COD_CLIE = T4.getText(); sql = "INSERT INTO contrato (`Tip_cont`,`Fech_cont`,`Tippago_cont`,`Cod_clie`) VALUES (?,?,?,? )"; try { PreparedStatement pst = cn.prepareStatement(sql); pst.setString(1, TIP_CONT); pst.setString(2, FECH_CONT); pst.setString(3, TIPPAGO_CONT); pst.setString(4, COD_CLIE); int a = pst.executeUpdate(); if (a>0){ JOptionPane.showMessageDialog(null ,"Registro Guardado Con exito"); bloquear(); cargar(""); limpiar(); } } catch (SQLException ex) { Logger.getLogger(Inmueble.class.getName()).log(Level.SEVERE, null, ex); }
  • 14. // TODO addyourhandlingcodehere: } privatevoidauxKeyReleased(java.awt.event.KeyEventevt) { cargar(aux.getText()); // TODO addyourhandlingcodehere: } http://www.lawebdelprogramador.com/img/btn_previsualizar.png En verdad agradecería toto tipo de ayuda