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

📄 get_ip1.java

📁 这个是朋友作的毕业设计
💻 JAVA
字号:
package Resource_Selection;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import com.borland.dx.sql.dataset.*;


public class get_ip1 extends JFrame {
  JPanel contentPane;
  JTextField jTextField1 = new JTextField();
  JButton jButton1 = new JButton();

  //Construct the frame
  public get_ip1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception  {
    contentPane = (JPanel) this.getContentPane();
    jTextField1.setText(Resource_Selection.user.ip_updata.ip);
    jTextField1.setBounds(new Rectangle(18, 36, 230, 29));
    contentPane.setLayout(null);
    this.setSize(new Dimension(367, 114));
    this.setTitle("请输入IP地址");
    jButton1.setBounds(new Rectangle(263, 35, 67, 30));
    jButton1.setText("确定");
    jButton1.addActionListener(new get_ip1_jButton1_actionAdapter(this));
    contentPane.add(jTextField1, null);
    contentPane.add(jButton1, null);
  }
  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      this.dispose();
    }
  }

  void jButton1_actionPerformed(ActionEvent e) {
    String table="";
    table=jTextField1.getText();
    String sql = "select * from computer where 地址 ='" + table + "'";
    String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
    String connectionURL = "jdbc:odbc:computer"; //driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\WINDOWS\\Desktop\\desktop\\毕业设计\\Grid\\computer.mdb";
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String adm = null;
    try {
      Class.forName(driverName).newInstance();
      con = DriverManager.getConnection(connectionURL);
      stmt = con.createStatement();
      rs = stmt.executeQuery(sql);
      if (rs.next()) {
        Resource_Selection.user.ip_updata.ip = table;
        this.dispose();
        new updata();
      }
      else {
        new err_null_ip();
        jTextField1.setText("");
      }
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }

    finally {
      try {
        rs.close();
        stmt.close();
        con.close();
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
  }

class get_ip1_jButton1_actionAdapter implements java.awt.event.ActionListener {
  get_ip1 adaptee;

  get_ip1_jButton1_actionAdapter(get_ip1 adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton1_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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