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

📄 c04bf4c4a9fc001d1745a9bad977883d

📁 java做的机票查询系统、 仅供初学者参考!
💻
字号:
/*
 * MainFrame.java
 *
 * Created on __DATE__, __TIME__
 */

package Flight;
import java.util.*;
/**
 *
 * @author  __USER__
 */
public class MainFrame extends javax.swing.JFrame {

	/** Creates new form MainFrame */
	public MainFrame() {
		initComponents();
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jPanel1 = new javax.swing.JPanel();
		jLabel1 = new javax.swing.JLabel();
		txtCity = new javax.swing.JTextField();
		jLabel2 = new javax.swing.JLabel();
		txtRecity = new javax.swing.JTextField();
		jLabel3 = new javax.swing.JLabel();
		txtNum = new javax.swing.JTextField();
		btnSelect = new javax.swing.JButton();
		btnRemake = new javax.swing.JButton();
		jMenuBar1 = new javax.swing.JMenuBar();
		jMenu1 = new javax.swing.JMenu();
		jMenuItem1 = new javax.swing.JMenuItem();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		jLabel1.setFont(new java.awt.Font("宋体", 1, 12));
		jLabel1.setText("\u51fa\u53d1\u57ce\u5e02\uff1a");

		txtCity.setFont(new java.awt.Font("宋体", 1, 12));

		jLabel2.setFont(new java.awt.Font("宋体", 1, 12));
		jLabel2.setText("\u76ee\u7684\u57ce\u5e02\uff1a");

		txtRecity.setFont(new java.awt.Font("宋体", 1, 12));

		jLabel3.setFont(new java.awt.Font("宋体", 1, 12));
		jLabel3.setText("\u4e58\u5ba2\u4eba\u6570\uff1a");

		txtNum.setFont(new java.awt.Font("宋体", 1, 12));

		btnSelect.setFont(new java.awt.Font("宋体", 1, 14));
		btnSelect.setText("\u67e5\u8be2");
		btnSelect.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btnSelectActionPerformed(evt);
			}
		});

		btnRemake.setFont(new java.awt.Font("宋体", 1, 14));
		btnRemake.setText("\u91cd\u7f6e");
		btnRemake.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btnRemakeActionPerformed(evt);
			}
		});

		org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
				jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout
				.setHorizontalGroup(jPanel1Layout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(
								jPanel1Layout
										.createSequentialGroup()
										.add(29, 29, 29)
										.add(
												jPanel1Layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.TRAILING,
																false)
														.add(
																org.jdesktop.layout.GroupLayout.LEADING,
																jLabel3,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.add(
																org.jdesktop.layout.GroupLayout.LEADING,
																jLabel1,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.add(18, 18, 18)
										.add(
												jPanel1Layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING,
																false)
														.add(txtNum)
														.add(
																txtCity,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																86,
																Short.MAX_VALUE))
										.add(35, 35, 35)
										.add(
												jPanel1Layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING)
														.add(
																jPanel1Layout
																		.createSequentialGroup()
																		.add(
																				jLabel2)
																		.add(
																				18,
																				18,
																				18)
																		.add(
																				txtRecity,
																				org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																				93,
																				Short.MAX_VALUE))
														.add(
																jPanel1Layout
																		.createSequentialGroup()
																		.add(
																				btnSelect)
																		.addPreferredGap(
																				org.jdesktop.layout.LayoutStyle.RELATED,
																				50,
																				Short.MAX_VALUE)
																		.add(
																				btnRemake)))
										.add(32, 32, 32)));
		jPanel1Layout
				.setVerticalGroup(jPanel1Layout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.add(
												jPanel1Layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.BASELINE)
														.add(
																jLabel1,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																26,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(
																txtCity,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(
																jLabel2,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																24,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(
																txtRecity,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(42, 42, 42)
										.add(
												jPanel1Layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.BASELINE)
														.add(
																jLabel3,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																26,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(
																txtNum,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(
																btnSelect,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																32,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(
																btnRemake,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																34,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.addContainerGap(22, Short.MAX_VALUE)));

		jMenu1.setText("\u7cfb\u7edf");

		jMenuItem1.setText("\u9000\u51fa");
		jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jMenuItem1ActionPerformed(evt);
			}
		});
		jMenu1.add(jMenuItem1);

		jMenuBar1.add(jMenu1);

		setJMenuBar(jMenuBar1);

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(
				layout.createSequentialGroup().add(34, 34, 34).add(jPanel1,
						org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
						org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
						org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(29, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(
				layout.createSequentialGroup().add(20, 20, 20).add(jPanel1,
						org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
						org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
						org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(23, Short.MAX_VALUE)));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void btnSelectActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:查询按钮
		try {
			String lcavccity=txtCity.getText();
			String destination=txtRecity.getText();
			String num=txtNum.getText();
			//int econum=Integer.parseInt(num);
			
			if("".equals(lcavccity)) {
				javax.swing.JOptionPane.showMessageDialog(this, "请输入出发城市","提示",javax.swing.JOptionPane.ERROR_MESSAGE);
				txtCity.requestFocus();
				return;
				
			}
			else if("".equals(destination)) {
				javax.swing.JOptionPane.showMessageDialog(this, "请输入目的城市!","提示",javax.swing.JOptionPane.ERROR_MESSAGE);
				txtRecity.requestFocus();
				return;
			}
			else if("".equals(num)) {
				javax.swing.JOptionPane.showMessageDialog(this, "请输入人数!","提示",javax.swing.JOptionPane.ERROR_MESSAGE);
				txtNum.requestFocus();
				return;
			}
			Bean bean=new Bean();
			DAO dao=new DAO();
			//ArrayList al=new ArrayList();
			bean=dao.select(lcavccity, destination);
			if(bean != null) {
				javax.swing.JOptionPane.showMessageDialog(this, bean.toString()+bean.getFlightno());
				
			}
			else {
				javax.swing.JOptionPane.showMessageDialog(this, "查询失败!","提示",javax.swing.JOptionPane.ERROR_MESSAGE);
				
			}	
			
		}
		catch(java.lang.NumberFormatException nfe) {
			nfe.printStackTrace();
			
		}
		
		
		
	}

	private void btnRemakeActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:重置按钮
		txtCity.setText("");
		txtRecity.setText("");
		txtNum.setText("");
		txtCity.requestFocus();

	}

	private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		MainFrame.this.dispose();
	}

	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new MainFrame().setVisible(true);
			}
		});
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JButton btnRemake;
	private javax.swing.JButton btnSelect;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JMenu jMenu1;
	private javax.swing.JMenuBar jMenuBar1;
	private javax.swing.JMenuItem jMenuItem1;
	private javax.swing.JPanel jPanel1;
	private javax.swing.JTextField txtCity;
	private javax.swing.JTextField txtNum;
	private javax.swing.JTextField txtRecity;
	// End of variables declaration//GEN-END:variables

}

⌨️ 快捷键说明

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