1、火车售票系统完整代码package com.yue;import java.awt.Color;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.CallableStatement;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet
2、;import java.sql.SQLException;import java.sql.Statement;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextArea;import javax.swing.JTextField;public c
3、lass BuyPanel extends JPanel StringBuffer sb = new StringBuffer(); private boolean flag = false; JTextArea jtArea = new JTextArea(10, 78); JLabel buyLabel = new JLabel(订票); JTextField fId = new JTextField(7); JTextField ftid = new JTextField(7); JTextField fche = new JTextField(7); JTextField fzhang
4、shu = new JTextField(7); JTextField fbodyId = new JTextField(7); JPasswordField jpField = new JPasswordField(7); public JPanel getBuypn() JPanel pan = new JPanel(); GridBagLayout layout = new GridBagLayout(); pan.setLayout(layout); GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 100, 100,
5、 GridBagConstraints.NONE, GridBagConstraints.WEST); pan.add(buyLabel, con); con = getGridBagConstraints(0, 2, 1, 1, 100, 100, GridBagConstraints.NONE, GridBagConstraints.WEST); pan.add(new pan3(), con); con = getGridBagConstraints(0, 3, 1, 1, 100, 100, GridBagConstraints.NONE, GridBagConstraints.WES
6、T); pan.add(new pan4(), con); con = getGridBagConstraints(0, 4, 1, 1, 100, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); pan.add(new pan5(), con); this.setLocation(270, 150); this.add(pan); return pan; /* * 定义下面购票操作区面板pan3 * * author Administrator * */ class pan3 extends JPanel JLabel lId
7、= new JLabel( 车票号码 ); JLabel ltid = new JLabel( 车票号码 ); JLabel che = new JLabel( 车 次 ); JLabel lbodyId = new JLabel( 身份证号 ); JLabel password = new JLabel( 密码 ); JLabel lzhangshu = new JLabel( 所需张数 ); JLabel la1 = new JLabel( ); JLabel la2 = new JLabel( ); JButton sureButton = new JButton(查询确认); JBut
8、ton buyButton = new JButton(确认购票); public pan3() buyButton.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) UpdateUser(); if (flag=true) UpdateTrain(); System.out.println(hjkasfhjkaf); ); sureButton.addActionListener(new ActionListener() Override public void
9、 actionPerformed(ActionEvent e) select(); ); GridBagLayout layout = new GridBagLayout(); this.setLayout(layout); GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(lId, con); con = getGridBagConstraints(1, 0, 1, 1, 0, 100, G
10、ridBagConstraints.NONE, GridBagConstraints.EAST); this.add(fId, con); con = getGridBagConstraints(8, 0, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(la2, con); con = getGridBagConstraints(9, 0, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(sur
11、eButton, con); con = getGridBagConstraints(0, 1, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(ltid, con); con = getGridBagConstraints(1, 1, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(ftid, con); con = getGridBagConstraints(2, 1, 1, 1, 0, 10
12、0, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(che, con); con = getGridBagConstraints(3, 1, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(fche, con); con = getGridBagConstraints(4, 1, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.ad
13、d(lbodyId, con); con = getGridBagConstraints(5, 1, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(fbodyId, con); con = getGridBagConstraints(0, 2, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(password, con); con = getGridBagConstraints(1, 2, 1,
14、 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(jpField, con); con = getGridBagConstraints(2, 2, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(lzhangshu, con); con = getGridBagConstraints(3, 2, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(fzhangshu, con); con = getGridBagConstraints(8, 2, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST); this.add(la1, con); con = getGridBagConstraints(9, 2, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1