📄 applydialog.java~38~
字号:
package bank;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.awt.Font;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JComboBox.*;
import javax.swing.JTextField.*;
import java.lang.String.*;
//申请用户号类
public class ApplyDialog extends JDialog
{
public ApplyDialog(InterFrame frame, String title, boolean modal) {
super(frame, title, modal);
Frame1 = frame;
this.setLocation(250,200);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public ApplyDialog() {
this(null, "", false);
}
private InterFrame Frame1;
private String name;
private String city;
private String bankname;
private String mima;
private static int customer_id=10000;
private Connection con;
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
jLabel1.setFont(new java.awt.Font("华文细黑", Font.PLAIN, 16));
jLabel1.setForeground(Color.red);
jLabel1.setText("请正确填以下信息:");
jToggleButton1.addActionListener(new ApplyDialog_jToggleButton1_actionAdapter(this));
this.getContentPane().setBackground(Color.black);
jbankname.addActionListener(new ApplyDialog_jbankname_actionAdapter(this));
jButton1.addActionListener(new ApplyDialog_jButton1_actionAdapter(this));
this.getContentPane().add(jLabel1, new XYConstraints( -1, 1, 244, 37));
jToggleButton1.setText("重置");
jButton1.setText("确定");
jTextField3.setText("");
jTextField2.setText("");
jTextField1.setText("");
jLabel5.setFont(new java.awt.Font("华文细黑", Font.PLAIN, 16));
jLabel5.setForeground(Color.red);
jLabel5.setText("选择银行:");
jLabel4.setFont(new java.awt.Font("华文细黑", Font.PLAIN, 16));
jLabel4.setForeground(Color.red);
jLabel4.setToolTipText("");
jLabel4.setText("城市");
jLabel3.setFont(new java.awt.Font("华文细黑", Font.PLAIN, 16));
jLabel3.setForeground(Color.red);
jLabel3.setText("密码:");
this.getContentPane().add(jTextField1, new XYConstraints(144, 59, 109, 28));
this.getContentPane().add(jLabel2, new XYConstraints(20, 54, 72, 34));
this.getContentPane().add(jLabel3, new XYConstraints(20, 96, 92, 36));
this.getContentPane().add(jLabel4, new XYConstraints(20, 137, 92, 33));
this.getContentPane().add(jLabel5, new XYConstraints(20, 181, 86, 30));
this.getContentPane().add(jTextField2, new XYConstraints(144, 95, 109, 28));
this.getContentPane().add(jTextField3, new XYConstraints(144, 137, 109, 28));
this.getContentPane().add(jbankname, new XYConstraints(144, 181, 109, 28));
this.getContentPane().add(jButton1, new XYConstraints(146, 251, 107, 32));
this.getContentPane().add(jToggleButton1,
new XYConstraints(283, 251, 98, 31));
jLabel2.setFont(new java.awt.Font("华文细黑", Font.PLAIN, 16));
jLabel2.setForeground(Color.red);
jLabel2.setText("姓名:");
try{
con = bankconnect.getconn();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select branch_name from branch");
String a;
while(rs.next())//一行行的移
{
a=rs.getString("branch_name");
jbankname.addItem(a);
}
rs.close();
con.close();
this.hide();
return;
}
catch(SQLException ex)
{
System.out.print("数据库连接出错!"+ex.toString());
}
}
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JButton jButton1 = new JButton();
JToggleButton jToggleButton1 = new JToggleButton();
JComboBox jbankname = new JComboBox();
public void jToggleButton1_actionPerformed(ActionEvent e) {
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
//连接数据库各银行的响应
public void jbankname_actionPerformed(ActionEvent e)
{
}
public void jButton1_actionPerformed(ActionEvent e)
{
name=jTextField1.getText();
mima=jTextField2.getText();
city=jTextField3.getText();
bankname="ggg";
customer_id++;
try
{
con = bankconnect.getconn();
Statement stmt = con.createStatement();
//WA/////
stmt.executeUpdate("insert customer(customer_id,customer_name,customer_city,customer_mima) values('"+customer_id+"','"+name+"','"+city+"','"+mima+"')");
con.close();
}
catch(SQLException ex)
{
System.out.println("数据库连接错误!"+ex.toString());
}
}
}
class ApplyDialog_jbankname_actionAdapter
implements ActionListener {
private ApplyDialog adaptee;
ApplyDialog_jbankname_actionAdapter(ApplyDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jbankname_actionPerformed(e);
}
}
class ApplyDialog_jButton1_actionAdapter
implements ActionListener {
private ApplyDialog adaptee;
ApplyDialog_jButton1_actionAdapter(ApplyDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class ApplyDialog_jToggleButton1_actionAdapter
implements ActionListener {
private ApplyDialog adaptee;
ApplyDialog_jToggleButton1_actionAdapter(ApplyDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jToggleButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -