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

📄 newjframe1.java

📁 能简单的实现商品的查询
💻 JAVA
字号:
/* * NewJFrame1.java * * Created on 2008 12:16 *///package shop;/** * * @author  ldwin */import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.*;import javax.swing.event.*;public class NewJFrame1 extends javax.swing.JFrame {        /** Creates new form NewJFrame1 */    public NewJFrame1() {        initComponents();    }        /** 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.     */    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        jLabel1 = new javax.swing.JLabel();        jLabel2 = new javax.swing.JLabel();        jLabel3 = new javax.swing.JLabel();        jFormattedTextField1 = new javax.swing.JFormattedTextField();        jPasswordField1 = new javax.swing.JPasswordField();        jButton1 = new javax.swing.JButton();        jButton2 = new javax.swing.JButton();        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);        jLabel1.setText("vip\u59d3\u540d");        jLabel2.setText("\u5bc6\u7801");        jLabel3.setText("vip\u767b\u9646");        jButton1.setText("\u786e\u5b9a");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        jButton2.setText("\u53d6\u6d88");        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton2ActionPerformed(evt);            }        });        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(layout.createSequentialGroup()                        .addGap(55, 55, 55)                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                            .addComponent(jLabel1)                            .addComponent(jLabel2))                        .addGap(45, 45, 45)                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)                            .addComponent(jPasswordField1)                            .addComponent(jFormattedTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)                            .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING)                            .addComponent(jButton2)))                    .addGroup(layout.createSequentialGroup()                        .addGap(166, 166, 166)                        .addComponent(jLabel3)))                .addContainerGap(110, Short.MAX_VALUE))        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addGap(31, 31, 31)                .addComponent(jLabel3)                .addGap(27, 27, 27)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel1)                    .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(42, 42, 42)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel2)                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(42, 42, 42)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jButton1)                    .addComponent(jButton2))                .addContainerGap(78, Short.MAX_VALUE))        );        pack();    }// </editor-fold>//GEN-END:initComponentsprivate void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed    // TODO add your handling code here:    jFormattedTextField1.setText("");        jPasswordField1.setText("");}//GEN-LAST:event_jButton2ActionPerformedprivate void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed    // TODO add your handling code here:       Connection con;			PreparedStatement sql;			ResultSet rs;			try{ Class.forName("sun.jdbc.odbc.JdbcObdcDriver");}			catch(ClassNotFoundException e)			{System.out.println(e);}			try			{				con=DriverManager.getConnection("jdbc:odbc:sun","","");				sql=con.prepareStatement("select * from denglu");				rs=sql.executeQuery();							 				while(rs.next())								{					if(jFormattedTextField1.getText().equals(rs.getString(1))&& jPasswordField1.getText().equals(rs.getString(2)))					 {System.out.println("all right");}				      try{                                              Runtime ce=Runtime.getRuntime();                                            ce.exec("javac NewJFrame4.java");                                            ce.exec("java NewJFrame4");                                                  }                                           catch(Exception e)                                              {  System.out.println(e);}				                                }				  				con.close();			}			catch(SQLException u)			{				System.out.println(u);			}}//GEN-LAST:event_jButton1ActionPerformed        /**     * @param args the command line arguments     */    public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new NewJFrame1().setVisible(true);            }        });    }        // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JFormattedTextField jFormattedTextField1;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JPasswordField jPasswordField1;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

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