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

📄 searchflight.java

📁 一个用java实现 的飞机订票系统,超级好用....
💻 JAVA
字号:
package com.zhu.server;import java.awt.BorderLayout;import java.awt.Color;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import java.util.HashSet;import javax.swing.*;import org.hibernate.Session;import org.hibernate.Transaction;import com.zhu.dao.FlightDAO;import com.zhu.entity.*;import com.zhu.util.HbnUtil;/* *  @author zhutingfa */public class SearchFlight extends JDialog implements ActionListener{	private JLabel label0,label1,label3,label4,        label5,label6,label7,label8,label9,label10;   private JButton ok,cancel;   private JTextField t,t1,t2,t3,t4,t5,t6;		public SearchFlight(JFrame jf) {			super(jf,"查询航班");			label0=new JLabel("查询航班");			label0.setForeground(Color.RED);			label1=new JLabel("航 班 号:");			label3=new JLabel("开始日期:");			label4=new JLabel("年");			label5=new JLabel("月");			label6=new JLabel("日");			label7=new JLabel("结至日期:");			label8=new JLabel("年");			label9=new JLabel("月");			label10=new JLabel("日");			t=new JTextField(20);			t1=new JTextField(5);			t2=new JTextField(5);			t3=new JTextField(5);			t4=new JTextField(5);			t5=new JTextField(5);			t6=new JTextField(5);			ok=new JButton("查询");ok.addActionListener(this);			cancel=new JButton("取消");cancel.addActionListener(this);			init();			showMe();		}	public void init(){		JPanel p=new JPanel();		JPanel p1=new JPanel();		JPanel p2=new JPanel();		JPanel p3=new JPanel();		JPanel p4=new JPanel();		JPanel p5=new JPanel();		JPanel p6=new JPanel();		p1.add(label0);		p3.setLayout(new FlowLayout(FlowLayout.LEFT));		p4.setLayout(new FlowLayout(FlowLayout.LEFT));		p3.add(label1);p3.add(t);		p.setLayout(new FlowLayout(FlowLayout.CENTER));		p.add(ok);p.add(cancel);		p5.add(label3);p5.add(t1);		p5.add(label4);p5.add(t2);		p5.add(label5);p5.add(t3);p5.add(label6);		p6.add(label7);p6.add(t4);		p6.add(label8);p6.add(t5);		p6.add(label9);p6.add(t6);p6.add(label10);		p2.add(p3);		p2.add(p4);		p2.add(p5);		p2.add(p6);		this.add(p1,BorderLayout.NORTH);		this.add(p2,BorderLayout.CENTER);		this.add(p,BorderLayout.SOUTH);			}			private void showMe(){		this.setSize(400,200);		this.setLocation(300, 150);		this.setVisible(true);		this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);	}	public void actionPerformed(ActionEvent e){		if(e.getActionCommand().equals("查询")){			HashSet hsNew=new HashSet();			MyDate sd=new MyDate(Integer.parseInt(t1.getText()),Integer.parseInt(t2.getText()),Integer.parseInt(t3.getText()));			MyDate ed=new MyDate(Integer.parseInt(t4.getText()),Integer.parseInt(t5.getText()),Integer.parseInt(t6.getText()));			try { 				FlightDAO f=ServerMainClass.flightDao;				Session s=HbnUtil.getCurrentSession();				Transaction tt=s.beginTransaction();				HashSet hs=(HashSet)f.getAllFlights();				tt.commit();				for(Object obj:hs){					Flight ft=(Flight)obj;					FlightSchedular fsc=ft.getSch();					if(fsc.getFlightNumber().equals(t.getText())&&sd.compareTo(ft.getDate())<=0&&ed.compareTo(ft.getDate())>=0)						hsNew.add(ft);									}				this.dispose();				ArrayList arr=new ArrayList();				arr.addAll(hsNew);				((JFrame)(this.getOwner())).setContentPane(new FlightListPanel(t.getText(),sd,ed,arr));				this.getOwner().setVisible(true);			} catch (Exception e1) {				e1.printStackTrace();			}		}		if(e.getActionCommand().equals("取消")){			this.dispose();		}	}}

⌨️ 快捷键说明

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