📄 agreciudad.java
字号:
/* * agreciudad.java * * Created on 25 de junio de 2004, 01:07 AM *//** * * @author GeBuSe */import javax.swing.table .*;import java.sql.*;public class agreciudad extends javax.swing.JDialog {Connection pcon; /** Creates new form agreciudad */ public agreciudad(java.awt.Frame parent, boolean modal,Connection ppconn) { super(parent, modal); initComponents(); setSize(500, 400); pcon=ppconn; } /** 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 aceptar = new javax.swing.JButton(); codigo = new javax.swing.JTextField(); ciudad = new javax.swing.JTextField(); label1 = new java.awt.Label(); label2 = new java.awt.Label(); jButton1 = new javax.swing.JButton(); getContentPane().setLayout(null); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); aceptar.setText("aceptar"); aceptar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { aceptarActionPerformed(evt); } }); getContentPane().add(aceptar); aceptar.setBounds(80, 220, 80, 30); getContentPane().add(codigo); codigo.setBounds(180, 70, 60, 20); getContentPane().add(ciudad); ciudad.setBounds(180, 110, 60, 20); label1.setText("codigo"); getContentPane().add(label1); label1.setBounds(80, 70, 41, 20); label2.setText("ciudad"); getContentPane().add(label2); label2.setBounds(80, 110, 41, 20); jButton1.setText("salir"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); getContentPane().add(jButton1); jButton1.setBounds(190, 220, 59, 26); pack(); }//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformeddispose(); // Add your handling code here: }//GEN-LAST:event_jButton1ActionPerformed private void aceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aceptarActionPerformedStatement stmt; String a=codigo.getText(); String b=ciudad.getText(); try { String consulta; stmt = pcon.createStatement(); consulta="insert into ciudad values('"+ a+"','"+ b+"') "; stmt.executeUpdate(consulta); stmt.close(); dispose(); } catch (SQLException ex) { System.out.println("Hubo un error en la consulta ... :"+ex); } // Add your handling code here: // Add your handling code here: }//GEN-LAST:event_aceptarActionPerformed /** 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 */ /* public static void main(String args[]) { new agreciudad(new javax.swing.JFrame(), true).show(); }*/ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton aceptar; private javax.swing.JTextField ciudad; private javax.swing.JTextField codigo; private javax.swing.JButton jButton1; private java.awt.Label label1; private java.awt.Label label2; // End of variables declaration//GEN-END:variables }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -