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

📄 saletickets.java~83~

📁 一个可以实现联网售票的火车售票管理系统
💻 JAVA~83~
字号:
package train.gui;import javax.swing.*;import java.awt.*;import com.borland.jbcl.layout.*;import java.awt.event.*;import javax.swing.event.*;import javax.swing.table.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: 沈阳化工学院计算机</p> * @author 彭胜勇  胡林 * @version 1.0 */public class SaleTickets extends JFrame {  JTable trainjTable = new JTable();  XYLayout xYLayout1 = new XYLayout();  JScrollPane jScrollPane1 = new JScrollPane();  JPanel jPanel1 = new JPanel();  JPanel jPanel2 = new JPanel();  JLabel trainIDjLabel = new JLabel();  JTextField jTextField1 = new JTextField();  JButton searchjButton = new JButton();  JPanel jPanel3 = new JPanel();  XYLayout xYLayout2 = new XYLayout();  XYLayout xYLayout3 = new XYLayout();  XYLayout xYLayout4 = new XYLayout();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  ButtonGroup buttonGroup1 = new ButtonGroup();  JRadioButton IDjRadioButton = new JRadioButton();  JRadioButton stajRadioButton = new JRadioButton();  JLabel jLabel3 = new JLabel();  JLabel jLabel4 = new JLabel();  JLabel jLabel5 = new JLabel();  JButton canceljButton = new JButton();  JLabel jLabel6 = new JLabel();  JLabel jLabel7 = new JLabel();  JTextField IDjTextField = new JTextField();  JLabel jLabel8 = new JLabel();  JTextField fromjTextField = new JTextField();  JLabel jLabel9 = new JLabel();  JTextField endjTextField = new JTextField();  JLabel jLabel10 = new JLabel();  JTextField throughjTextField = new JTextField();  JLabel jLabel11 = new JLabel();  JLabel jLabel12 = new JLabel();  JLabel jLabel13 = new JLabel();  JTextField ticketNumjTextField = new JTextField();  JLabel jLabel14 = new JLabel();  JTextField sumjTextField = new JTextField();  JLabel jLabel15 = new JLabel();  JTextField payjTextField = new JTextField();  JLabel jLabel16 = new JLabel();  JTextField backjTextField = new JTextField();  JButton okjButton = new JButton();  JButton printjButton = new JButton();  JButton exitjButton = new JButton();  JComboBox ticketjComboBox ;//= new JComboBox();  JComboBox carragejComboBox; //= new JComboBox();  JComboBox datejComboBox;  JComboBox frmStajComboBox = new JComboBox();  JComboBox arrStajComboBox;// = new JComboBox();//= new JComboBox();  public SaleTickets() throws HeadlessException {    try {      jbInit();      this.setLocation(100,100);      this.setSize(625,550);      this.setResizable(false);      this.setVisible(true);    }    catch(Exception e) {      e.printStackTrace();    }  }  public static void main(String[] args) throws HeadlessException {    SaleTickets saleTickets1 = new SaleTickets();  }  private void jbInit() throws Exception {    Object [] carrage={"硬座","软座","硬卧","软卧"};    Object [] ticket={"全","孩","学","残","免","探","半","单卧小孩","团","军"};    Object [] date={"1日","2日","3日","4日"};    carragejComboBox=new JComboBox(carrage);    ticketjComboBox=new JComboBox(ticket);    datejComboBox=new JComboBox(date);    this.setTitle("售票");    jPanel2.setBorder(BorderFactory.createLoweredBevelBorder());    jPanel2.setLayout(xYLayout2);    this.getContentPane().setLayout(xYLayout1);    xYLayout1.setWidth(617);    xYLayout1.setHeight(491);    jPanel1.setBorder(BorderFactory.createLoweredBevelBorder());    jPanel1.setLayout(xYLayout4);    trainIDjLabel.setAlignmentX((float) 0.0);    trainIDjLabel.setText("车次");    searchjButton.setActionCommand("jButton1");    searchjButton.setText("查询");    jPanel3.setBorder(BorderFactory.createLoweredBevelBorder());    jPanel3.setLayout(xYLayout3);    jLabel1.setText("起始站 ");    jLabel2.setPreferredSize(new Dimension(55, 16));    jLabel2.setText("按车次查询");    IDjRadioButton.setRequestFocusEnabled(true);    IDjRadioButton.setActionCommand("");    IDjRadioButton.setText("");    stajRadioButton.setText("");    jLabel3.setPreferredSize(new Dimension(55, 16));    jLabel3.setText("按车站查询");    jLabel4.setOpaque(false);    jLabel4.setText("到达站");    jLabel5.setHorizontalTextPosition(SwingConstants.TRAILING);    jLabel5.setText("日期");    jTextField1.setText("");    canceljButton.setRolloverEnabled(false);    canceljButton.setText("取消");    jLabel6.setDoubleBuffered(false);    jLabel6.setPreferredSize(new Dimension(110, 16));    jLabel6.setHorizontalAlignment(SwingConstants.CENTER);    jLabel6.setText("请确认您所选择的车次!");    jLabel7.setText("车次");    jLabel8.setOpaque(false);    jLabel8.setText("始发站 ");    jLabel9.setText("终点站");    jLabel10.setMaximumSize(new Dimension(22, 16));    jLabel10.setText("途经");    fromjTextField.setAlignmentX((float) 0.5);    fromjTextField.setEditable(false);    fromjTextField.setSelectionEnd(0);    fromjTextField.setText("");    IDjTextField.setAlignmentX((float) 0.5);    IDjTextField.setEditable(false);    IDjTextField.setSelectionEnd(0);    IDjTextField.setText("");    endjTextField.setEditable(false);    endjTextField.setSelectionEnd(0);    endjTextField.setText("");    throughjTextField.setEditable(false);    throughjTextField.setSelectionEnd(0);    throughjTextField.setText("");    jLabel11.setText("车厢类别");    jLabel12.setMaximumSize(new Dimension(44, 16));    jLabel12.setText("车票类别");    jLabel13.setPreferredSize(new Dimension(44, 16));    jLabel13.setText("车票数量");    jLabel14.setOpaque(false);    jLabel14.setText("总票价");    jLabel15.setOpaque(false);    jLabel15.setText("实付");    jLabel16.setOpaque(false);    jLabel16.setText("找零");    backjTextField.setAlignmentX((float) 0.5);    backjTextField.setSelectionEnd(0);    backjTextField.setText("");    sumjTextField.setSelectionEnd(0);    sumjTextField.setText("");    ticketNumjTextField.setAlignmentX((float) 0.5);    ticketNumjTextField.setSelectionEnd(0);    ticketNumjTextField.setText("");    payjTextField.setSelectionEnd(0);    payjTextField.setText("");    okjButton.setToolTipText("");    okjButton.setActionCommand("确定");    okjButton.setText("确定");    printjButton.setText("打印");    exitjButton.setActionCommand("退出");    exitjButton.setText("退出");    frmStajComboBox.setEditable(true);    arrStajComboBox.setAlignmentX((float) 0.5);    arrStajComboBox.setToolTipText("");    arrStajComboBox.setEditable(true);    this.getContentPane().add(jPanel1,           new XYConstraints(18, 10, 582, 79));    jPanel1.add(jLabel6, new XYConstraints(2, 0, 575, 22));    jPanel1.add(jLabel7,           new XYConstraints(19, 43, 30, 21));    jPanel1.add(IDjTextField, new XYConstraints(60, 41, 68, 24));    jPanel1.add(fromjTextField,  new XYConstraints(198, 41, 68, 24));    jPanel1.add(jLabel8,   new XYConstraints(152, 43, 42, 21));    jPanel1.add(jLabel9, new XYConstraints(289, 44, 42, 21));    jPanel1.add(endjTextField, new XYConstraints(345, 41, 68, 24));    jPanel1.add(jLabel10, new XYConstraints(444, 43, 34, 21));    jPanel1.add(throughjTextField, new XYConstraints(480, 41, 68, 24));    this.getContentPane().add(jScrollPane1,   new XYConstraints(18, 190, 582, 172));    this.getContentPane().add(jPanel2,    new XYConstraints(18, 92, 582, 95));    jPanel2.add(searchjButton,    new XYConstraints(483, 13, 74, 26));    this.getContentPane().add(jPanel3,  new XYConstraints(18, 365, 582, 116));    jPanel3.add(printjButton,          new XYConstraints(479, 44, 77, 28));    jPanel3.add(exitjButton,            new XYConstraints(479, 79, 77, 28));    jPanel3.add(okjButton,    new XYConstraints(479, 6, 77, 28));    jPanel3.add(jLabel13,  new XYConstraints(194, 7, 58, 27));    jPanel3.add(ticketNumjTextField, new XYConstraints(284, 10, 69, 20));    jPanel3.add(sumjTextField, new XYConstraints(284, 49, 69, 20));    jPanel3.add(backjTextField, new XYConstraints(284, 87, 69, 20));    jPanel3.add(jLabel16, new XYConstraints(194, 84, 58, 27));    jPanel3.add(jLabel14, new XYConstraints(194, 46, 58, 27));    jPanel3.add(jLabel15,  new XYConstraints(29, 84, 58, 27));    jPanel3.add(payjTextField, new XYConstraints(97, 87, 69, 20));    jPanel3.add(ticketjComboBox, new XYConstraints(97, 49, 69, 20));    jPanel3.add(carragejComboBox, new XYConstraints(97, 10, 69, 20));    jPanel3.add(jLabel11, new XYConstraints(29, 7, 58, 27));    jPanel3.add(jLabel12, new XYConstraints(29, 46, 58, 27));    jScrollPane1.getViewport().add(trainjTable, null);    buttonGroup1.add(IDjRadioButton);    buttonGroup1.add(stajRadioButton);    jPanel2.add(canceljButton,     new XYConstraints(483, 54, 73, 26));    jPanel2.add(datejComboBox, new XYConstraints(346, 14, 74, -1));    jPanel2.add(jLabel5, new XYConstraints(287, 15, 35, 25));    jPanel2.add(jLabel4,  new XYConstraints(287, 58, 43, 25));    jPanel2.add(jTextField1, new XYConstraints(196, 14, 70, -1));    jPanel2.add(trainIDjLabel, new XYConstraints(148, 15, 34, 25));    jPanel2.add(jLabel1,   new XYConstraints(148, 58, 42, 25));    jPanel2.add(jLabel3,  new XYConstraints(53, 58, 73, 25));    jPanel2.add(IDjRadioButton, new XYConstraints(21, 15, -1, -1));    jPanel2.add(stajRadioButton, new XYConstraints(19, 58, 33, 25));    jPanel2.add(jLabel2,  new XYConstraints(53, 15, 74, 25));    jPanel2.add(frmStajComboBox,  new XYConstraints(194, 62, 71, 23));    jPanel2.add(arrStajComboBox,    new XYConstraints(347, 62, 71, 23));  }  public String getTrainID() {        return this.jTextField1.getText();    }    public void setArrStation(Object []list) {         arrStajComboBox=new JComboBox(list);    }  public void setContent(java.util.List list) {        trainjTable.updateUI();    }    public int getTrainjTableSelectedObject() {          return trainjTable.getSelectedRow();      }      public void setTrainjTableSelectedObject(int i) {          trainjTable.changeSelection(i, -1, true, false);      }      public void setTrainID(String trainID) {          this.IDjTextField.setText(trainID);      }      public void setFromSta(String fromSta) {          this.fromjTextField.setText(fromSta);      }      public void setEndSta(String endSta) {          this.endjTextField.setText(endSta);            }      public void setThrSta(String thrSta) {         this.throughjTextField.setText(thrSta);             }      public String getFromStaIndex() {          return (String)this.frmStajComboBox.getSelectedItem();             }      public String getArrStaIndex() {          return (String)this.arrStajComboBox.getEditor().getItem();                      }   public void saleTicketsRegister(ActionListener al[], KeyListener staIndexList[],                                ListSelectionListener lslList[],                                TableModel atm) {        this.arrStajComboBox.getEditor().getEditorComponent().addKeyListener(staIndexList[0]);        this.searchjButton.addActionListener(al[0]);        this.trainjTable.getSelectionModel().addListSelectionListener(lslList[0]);        this.trainjTable.setModel(atm);        this.trainjTable.getSelectionModel().setSelectionMode(                ListSelectionModel.                SINGLE_SELECTION);    }}

⌨️ 快捷键说明

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