⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inicio.java

📁 ejemplo de java para conexion a base de datos
💻 JAVA
字号:
/* * inicio.java * * Created on 11 de junio de 2004, 11:45 PM *//** * * @author  GBS */import javax.swing.table .*;import java.sql.*;import javax.swing.JOptionPane ;public class inicio extends javax.swing.JFrame {public Connection pconn;      /** Creates new form inicio */    public inicio() {        initComponents();        pconn=null;        setSize(300,200);       }        /** 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        menu = new javax.swing.JMenuBar();        Archivo = new javax.swing.JMenu();        Salir = new javax.swing.JMenuItem();        Formulario = new javax.swing.JMenu();        Persona = new javax.swing.JMenuItem();        Ciudad = new javax.swing.JMenuItem();        Informe = new javax.swing.JMenu();        Listado = new javax.swing.JMenuItem();        Configuracion = new javax.swing.JMenu();        setup = new javax.swing.JMenuItem();        getContentPane().setLayout(null);        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                exitForm(evt);            }        });        Archivo.setText("Archivo");        Salir.setText("Salir");        Salir.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                SalirActionPerformed(evt);            }        });        Archivo.add(Salir);        menu.add(Archivo);        Formulario.setText("formulario");        Formulario.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                FormularioActionPerformed(evt);            }        });        Persona.setText("Persona");        Persona.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                PersonaActionPerformed(evt);            }        });        Formulario.add(Persona);        Ciudad.setText("Ciudad");        Ciudad.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                CiudadActionPerformed(evt);            }        });        Formulario.add(Ciudad);        menu.add(Formulario);        Informe.setText("Informe");        Informe.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                InformeActionPerformed(evt);            }        });        Listado.setText("Listado de Personas");        Listado.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                ListadoActionPerformed(evt);            }        });        Informe.add(Listado);        menu.add(Informe);        Configuracion.setText("Configuracion");        Configuracion.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                ConfiguracionActionPerformed(evt);            }        });        setup.setText("Setup");        setup.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                setupActionPerformed(evt);            }        });        Configuracion.add(setup);        menu.add(Configuracion);        setJMenuBar(menu);        pack();    }//GEN-END:initComponents    private void ListadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListadoActionPerformed    muestra_todo lista; if(pconn!=null) {                try            {                lista=new muestra_todo(this,true,pconn);                lista.show();             }            catch (Exception e)            {            } } else {JOptionPane.showMessageDialog(null, "Error en la coneccion"); }         }//GEN-LAST:event_ListadoActionPerformed    private void CiudadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CiudadActionPerformed         datosciudad ciudad; if(pconn!=null) {                try            {                ciudad=new datosciudad(this,true,pconn);                ciudad.show();             }            catch (Exception e)            {            } } else {      JOptionPane.showMessageDialog(null, "Error en la coneccion"); }     // Add your handling code here:    }//GEN-LAST:event_CiudadActionPerformed    private void SalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SalirActionPerformed        dispose();        // Add your handling code here:    }//GEN-LAST:event_SalirActionPerformed    private void InformeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_InformeActionPerformed        // Add your handling code here:    }//GEN-LAST:event_InformeActionPerformed    private void ConfiguracionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfiguracionActionPerformed        // Add your handling code here:    }//GEN-LAST:event_ConfiguracionActionPerformed    private void setupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setupActionPerformed       coneccion su;        try        {            su=new coneccion(this,true);            su.show();               pconn=su.recupera_coneccion();                  }        catch (Exception e)        {        }  // Add your handling code here:    }//GEN-LAST:event_setupActionPerformed    private void FormularioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FormularioActionPerformed      }//GEN-LAST:event_FormularioActionPerformed    private void PersonaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PersonaActionPerformed        datos u; if(pconn!=null) {                try            {                u=new datos(this,true,pconn);                u.show();             }            catch (Exception e)            {                            } } else{    JOptionPane.showMessageDialog(null, "Error en la coneccion");     }    }//GEN-LAST:event_PersonaActionPerformed        /** Exit the Application */    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm        System.exit(0);    }//GEN-LAST:event_exitForm        /**     * @param args the command line arguments     */    public static void main(String args[]){        new inicio().show();    }                // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JMenu Archivo;    private javax.swing.JMenuItem Ciudad;    private javax.swing.JMenu Configuracion;    private javax.swing.JMenu Formulario;    private javax.swing.JMenu Informe;    private javax.swing.JMenuItem Listado;    private javax.swing.JMenuItem Persona;    private javax.swing.JMenuItem Salir;    private javax.swing.JMenuBar menu;    private javax.swing.JMenuItem setup;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -