sendnotice.java~8~

来自「银行信用评估系统」· JAVA~8~ 代码 · 共 134 行

JAVA~8~
134
字号
package management;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.sql.*;import com.borland.dx.dataset.*;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;import javax.swing.border.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class sendNotice extends JPanel {  PreparedStatement pstmt2;String query2;Connection con;ResultSet rrs;  JLabel jLabel1 = new JLabel();  JTextField jTextField1 = new JTextField();  JTextArea jTextArea1 = new JTextArea();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  TitledBorder titledBorder1;  TitledBorder titledBorder2;  GridBagLayout gridBagLayout1 = new GridBagLayout();  public sendNotice() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit() throws Exception {    titledBorder1 = new TitledBorder("");    titledBorder2 = new TitledBorder("");    jLabel1.setFont(new java.awt.Font("Dialog", 0, 14));    jLabel1.setPreferredSize(new Dimension(0, 0));    jLabel1.setRequestFocusEnabled(true);    jLabel1.setText("信用卡号:");    this.setLayout(gridBagLayout1);    this.setForeground(Color.black);    jTextField1.setFont(new java.awt.Font("Dialog", 0, 14));    jTextField1.setText("");    jTextArea1.setBorder(BorderFactory.createLoweredBevelBorder());    jTextArea1.setSelectionStart(0);    jTextArea1.setText("");    jButton1.setFont(new java.awt.Font("Dialog", 0, 14));    jButton1.setText("发送");    jButton1.addActionListener(new sendNotice_jButton1_actionAdapter(this));    jButton2.setFont(new java.awt.Font("Dialog", 0, 14));    jButton2.setText("取消");    jButton2.addActionListener(new sendNotice_jButton2_actionAdapter(this));    try {    String url =        "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CCES";    String username = "sa";    String password = "";    con = DriverManager.getConnection(url, username, password);  }  catch (Exception ep) {System.out.print("系统错误,请重新运行。2");    ep.printStackTrace() ;}    this.add(jLabel1,  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(37, 28, 0, 0), 106, 35));    this.add(jTextField1,  new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(37, 20, 0, 105), 135, 8));    this.add(jTextArea1,  new GridBagConstraints(0, 1, 3, 1, 1.0, 1.0            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(41, 37, 0, 46), 313, 122));    this.add(jButton2,  new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(24, 45, 13, 102), 17, 0));    this.add(jButton1,  new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(24, 88, 13, 0), 22, -1));  }  void jButton1_actionPerformed(ActionEvent e) {    try{      query2 =          "insert into Notice(CreditcardId,Content) values('"+jTextField1.getText()+"','"+jTextArea1.getText()+"')";      pstmt2 = con.prepareStatement(query2);      rrs = pstmt2.executeQuery();    }    catch (Exception eep) {      jTextField1.setText("");    jTextArea1.setText("");    }  }  void jButton2_actionPerformed(ActionEvent e) {    jTextField1.setText("");    jTextArea1.setText("");  }}class sendNotice_jButton1_actionAdapter implements java.awt.event.ActionListener {  sendNotice adaptee;  sendNotice_jButton1_actionAdapter(sendNotice adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class sendNotice_jButton2_actionAdapter implements java.awt.event.ActionListener {  sendNotice adaptee;  sendNotice_jButton2_actionAdapter(sendNotice adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

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