网上的电子书《Jbuilder9基础教程》的全部例子源码

源代码在线查看: storepanel.java~28~

软件大小: 3216 K
上传用户: IsabellaJ
关键词: Jbuilder9 电子书 基础教程 源码
下载地址: 免注册下载 普通下载 VIP

相关代码

				package card;								import java.awt.*;				import javax.swing.*;				import java.awt.event.*;				import java.sql.*;				import java.lang.Number.*;				import java.util.*;				import java.text.*;												/**				 * Title: 				 * Description: 				 * Copyright: Copyright (c) 2003				 * Company: 				 * @author not attributable				 * @version 1.0				 */								public class storePanel extends JPanel {				  JLabel jLabel1 = new JLabel();				  JLabel jLabel2 = new JLabel();				  JLabel jLabel3 = new JLabel();				  JTextField jTextField1 = new JTextField();				  JButton jButton1 = new JButton();				  JButton jButton2 = new JButton();								  public storePanel(String Name,String ID,Connection connection1,eventFrame Frame1){				    try {				      UserName = Name;				      CardID = ID;				      con = connection1;				      eventFrame = Frame1;				      jbInit();				    }				    catch(Exception ex) {				      ex.printStackTrace();				    }				  }				  void jbInit() throws Exception {				    this.setPreferredSize(new Dimension(300, 300));				    this.setLayout(null);								    jLabel1.setFont(new java.awt.Font("Serif", 1, 18));				    jLabel1.setForeground(Color.blue);				    jLabel1.setText("用  户  名:");				    jLabel1.setBounds(new Rectangle(65, 30, 100, 30));								    jLabel2.setFont(new java.awt.Font("Serif", 1, 18));				    jLabel2.setText(UserName);				    jLabel2.setBounds(new Rectangle(165, 30, 100, 30));								    jLabel3.setFont(new java.awt.Font("Serif", 1, 18));				    jLabel3.setForeground(Color.blue);				    jLabel3.setText("存入数额:");				    jLabel3.setBounds(new Rectangle(65, 100, 100, 30));								    jTextField1.setText("0");				    jTextField1.setBounds(new Rectangle(165, 100, 100, 25));								    jButton1.setBounds(new Rectangle(70, 210, 70, 25));				    jButton1.setText("确定");				    jButton1.addActionListener(new storePanel_jButton1_actionAdapter(this));								    jButton2.setBounds(new Rectangle(160, 210, 70, 25));				    jButton2.setText("重置");				    jButton2.addActionListener(new storePanel_jButton2_actionAdapter(this));								    this.add(jLabel1, null);				    this.add(jLabel2, null);				    this.add(jLabel3, null);				    this.add(jTextField1, null);				    this.add(jButton1, null);				    this.add(jButton2, null);				  }								  void jButton2_actionPerformed(ActionEvent e) {				    jTextField1.setText("");				  }								  void jButton1_actionPerformed(ActionEvent e) {				    try{				         today = new java.text.SimpleDateFormat("yyyy-MM-dd", java.util.Locale.US);				         System.out.print(today.format(new java.util.Date()));				         storeInsert =con.createStatement();				         storeUpdate =con.createStatement();				         insertString = "insert event (CardID,EventMoney,EventDate) values ("+CardID+","+Integer.parseInt(jTextField1.getText())+",2003-09-15)";				         updateString = "update card set LeaveMoney = LeaveMoney + "+Integer.parseInt(jTextField1.getText().trim())+" where CardID = "+CardID;				         System.out.print(insertString);				         storeInsert.executeUpdate(insertString);				         storeUpdate.executeUpdate(updateString);				         eventFrame.toquery();				       }				       catch(SQLException ex){				         System.out.print("系统错误,请检测数据库");				       }				  }								  private String CardID;				  private Connection con;				  private Statement storeUpdate;				  private Statement storeInsert;				  private java.text.SimpleDateFormat today;				  private String UserName;				  private eventFrame eventFrame;								  private String updateString;				  private String insertString;				}								class storePanel_jButton2_actionAdapter implements java.awt.event.ActionListener {				  storePanel adaptee;								  storePanel_jButton2_actionAdapter(storePanel adaptee) {				    this.adaptee = adaptee;				  }				  public void actionPerformed(ActionEvent e) {				    adaptee.jButton2_actionPerformed(e);				  }				}								class storePanel_jButton1_actionAdapter implements java.awt.event.ActionListener {				  storePanel adaptee;								  storePanel_jButton1_actionAdapter(storePanel adaptee) {				    this.adaptee = adaptee;				  }				  public void actionPerformed(ActionEvent e) {				    adaptee.jButton1_actionPerformed(e);				  }				}			

相关资源