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

📄 addflight.java

📁 一套基于JAVA开发的完整版航空订票系统,代码简洁,适合JAVA初学者研究
💻 JAVA
字号:
package com.tarena.abs.server;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.io.*;import java.util.*;import com.tarena.abs.dao.*;import com.tarena.abs.model.*;public class AddFlight extends JDialog implements ActionListener{	private static final long serialVersionUID = -3145410955386840L;	private JLabel label0,label1,label2,label3,label4,label5,label6;	private JButton ok,cancel;	private JTextField t,t0,t1,t2,t3;	public AddFlight(JFrame frame){		super(frame,"添加航班");		label0=new JLabel("添加航班");		label1=new JLabel("航 班 号:");		label2=new JLabel("折    扣:");		label3=new JLabel("日    期:");		label4=new JLabel("年");		label5=new JLabel("月");		label6=new JLabel("日");		t=new JTextField(20);		t0=new JTextField(10);		t1=new JTextField(5);		t2=new JTextField(5);		t3=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();		p1.add(label0);		p3.setLayout(new FlowLayout(FlowLayout.LEFT));		p4.setLayout(new FlowLayout(FlowLayout.LEFT));		p3.add(label1);p3.add(t);		p4.add(label2);p4.add(t0);		p.setLayout(new FlowLayout(FlowLayout.LEFT));		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);		p2.add(p3,BorderLayout.NORTH);		p2.add(p4,BorderLayout.CENTER);		p2.add(p5,BorderLayout.SOUTH);		this.add(p1,BorderLayout.NORTH);		this.add(p2,BorderLayout.CENTER);		this.add(p,BorderLayout.SOUTH);			}			private void showMe(){		this.setSize(300,250);		this.setVisible(true);		this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);//?	}	public void actionPerformed(ActionEvent e){		if(e.getActionCommand().equals("添加")){			FlightDaoFromFile f=new FlightDaoFromFile(new File("./flightSchedular.dat"));			HashSet hs=(HashSet)f.getAllFlightSchedulars();			MyDate md=new MyDate(Integer.parseInt(t1.getText()),Integer.parseInt(t2.getText()),Integer.parseInt(t3.getText()) );			for(Object obj:hs){				FlightSchedular fsc=(FlightSchedular)obj;				if(fsc.getFlightNumber().equals(t.getText()) && fsc.hasFlight(md)){					Flight fl=fsc.createNewFlight(md,(Double.parseDouble(t0.getText())) );					boolean success=ServerMainClass.flightDao.addFlight(fl);					if(success){						JOptionPane.showMessageDialog(this,"添加航班成功!");						this.dispose();					}else{						JOptionPane.showMessageDialog(this,"添加航班失败!");						this.dispose();					}				}else{					JOptionPane.showMessageDialog(this,"添加航班失败!");					this.dispose();				}			}		}		if(e.getActionCommand().equals("取消")){			this.dispose();		}	}	}

⌨️ 快捷键说明

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