📄 eliminar.java
字号:
/* * eliminar.java * * Created on 29 de junio de 2004, 11:31 PM *//** * * @author GeBuSe */import java.sql .*;public class eliminar extends javax.swing.JDialog {Connection comi; /** Creates new form eliminar */ public eliminar(java.awt.Frame parent, boolean modal,Connection con) { super(parent, modal); initComponents(); setSize(400, 500); comi=con; } /** 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. */ private void initComponents() {//GEN-BEGIN:initComponents rut = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); label1 = new java.awt.Label(); jButton2 = new javax.swing.JButton(); getContentPane().setLayout(null); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); getContentPane().add(rut); rut.setBounds(250, 40, 120, 30); jButton1.setText("borrar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); getContentPane().add(jButton1); jButton1.setBounds(320, 100, 70, 26); label1.setText("Ingrese el rut"); getContentPane().add(label1); label1.setBounds(140, 40, 80, 30); jButton2.setText("Salir"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); getContentPane().add(jButton2); jButton2.setBounds(200, 100, 60, 26); pack(); }//GEN-END:initComponents private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformeddispose(); // Add your handling code here: }//GEN-LAST:event_jButton2ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformedStatement stmt;String consulta;try{stmt = comi.createStatement(); consulta ="delete from persona where rut='"+rut.getText()+"'";stmt.executeUpdate(consulta);stmt.close(); } catch (SQLException ex) { System.out.println("Hubo un error en la consulta ... :"+ex); } }//GEN-LAST:event_jButton1ActionPerformed /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog setVisible(false); dispose(); }//GEN-LAST:event_closeDialog /** * @param args the command line arguments */ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private java.awt.Label label1; private javax.swing.JTextField rut; // End of variables declaration//GEN-END:variables }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -