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

📄 mainframe.java

📁 航空航天订票系统 是数据库的课程设计 单机版
💻 JAVA
字号:
package GraphicsUI;

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;

public class MainFrame implements ActionListener {

	JFrame mf;

	JMenuBar mb;

	JMenu jm1;

	JMenuItem jm11;

	JMenuItem jm12;

	JMenu jm2;

	JMenuItem jm21;

	JMenuItem jm22;

	JMenuItem jm23;

	JMenu jm3;

	JMenuItem jm31;

	JMenuItem jm32;

	JMenuItem jm33;

	JMenu jm4;

	JMenuItem jm41;

	JMenuItem jm42;

	JMenuItem jm43;

	JMenu jm5;

	JMenuItem jm51;

	JMenuItem jm52;

	JMenu jm6;

	JMenuItem jm61;

	JMenuItem jm62;

	JMenu jm7;

	JMenuItem jm71;

	JMenuItem jm72;

	Toolkit kit;

	Dimension windowSize;

	JInternalFrame jif;

	JLabel jl;

	JMenu jm8;

	JMenuItem jm81;

	JMenuItem jm82;

	public MainFrame() {
		kit = Toolkit.getDefaultToolkit();
		windowSize = kit.getScreenSize();
		mf = new JFrame("航空航天订票系统");
		mf.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		mf.setBounds(windowSize.width / 2 - 350, windowSize.height / 2 - 250,
				700, 500);
		mb = new JMenuBar();
		mb.setSize(20, 20);
		jm1 = new JMenu("系统管理");
		jm11 = new JMenuItem("转换角色");
		jm11.addActionListener(this);
		jm12 = new JMenuItem("退出程序");
		jm12.addActionListener(this);
		jm1.add(jm11);
		jm1.addSeparator();
		jm1.add(jm12);
		// jm2 = new JMenu("航班设置");
		// jm21 = new JMenuItem("查看航班");
		// jm22 = new JMenuItem("新增航班");
		// jm23 = new JMenuItem("删除航班");
		// jm2.add(jm21);
		// jm2.addSeparator();
		// jm2.add(jm22);
		// jm2.addSeparator();
		// jm2.add(jm23);
		jm3 = new JMenu("航线设置");
		jm31 = new JMenuItem("查看航线");
		jm31.addActionListener(this);
		jm32 = new JMenuItem("新增航线");
		jm32.addActionListener(this);
		jm33 = new JMenuItem("删除航线");
		jm33.addActionListener(this);
		jm3.add(jm31);
		jm3.addSeparator();
		jm3.add(jm32);
		jm3.addSeparator();
		jm3.add(jm33);
		jm4 = new JMenu("统计分析");
		jm41 = new JMenuItem("查看订票情况");
		jm41.addActionListener(this);
		// jm42 = new JMenuItem("客户满意度统计");
		jm43 = new JMenuItem("客户意见综合");
		jm43.addActionListener(this);
		jm4.add(jm41);
		jm4.addSeparator();
		// jm4.add(jm42);
		// jm4.addSeparator();
		jm4.add(jm43);
		jm5 = new JMenu("系统关于");
		jm51 = new JMenuItem("关于");
		jm51.addActionListener(this);
		// jm52 = new JMenuItem("帮助");
		jm5.add(jm51);
		// jm5.addSeparator();
		// jm5.add(jm52);
		jm6 = new JMenu("前台操作");
		jm61 = new JMenuItem("航班订票");
		jm61.addActionListener(this);
		jm62 = new JMenuItem("航班退票");
		jm62.addActionListener(this);
		jm6.add(jm61);
		jm6.addSeparator();
		jm6.add(jm62);
		jm7 = new JMenu("客户查询");
		jm71 = new JMenuItem("航班查询");
		jm71.addActionListener(this);
		jm72 = new JMenuItem("服务评价");
		jm72.addActionListener(this);
		jm7.add(jm71);
		jm7.addSeparator();
		jm7.add(jm72);
		mb.add(jm1);
		// mb.add(jm2);
		mb.add(jm3);
		mb.add(jm4);
		mb.add(jm5);
		mb.add(jm6);
		mb.add(jm7);
		mf.add(mb, BorderLayout.NORTH);
		jif = new JInternalFrame("欢迎使用本系统", false, true, false, true);
		jl = new JLabel();
		jl.setIcon(new ImageIcon("Src/welcome.jpg"));
		jif.add(jl, BorderLayout.CENTER);
		mf.add(jif, BorderLayout.CENTER);
		jif.setVisible(true);
		mf.setResizable(false);
		mf.setVisible(true);
		mf.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				int n = JOptionPane
						.showConfirmDialog(null, "确定退出系统?", "提示",
								JOptionPane.YES_NO_OPTION,
								JOptionPane.QUESTION_MESSAGE);
				if (n == JOptionPane.YES_OPTION)
					mf.dispose();
			}
		});
	}

	public void handleInternalFrame(JInternalFrame njif) {
		jif.doDefaultCloseAction();
		mf.add(njif, BorderLayout.CENTER);
		jif = njif;
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == jm11) {
			this.mf.dispose();
			new LogOn();
		}
		if (e.getSource() == jm31) {
			handleInternalFrame(new SelectFlight(this).jif);
		}
		if (e.getSource() == jm61) {
			handleInternalFrame(new OrderOperation(this).jif);
		}
		if (e.getSource() == jm62) {
			handleInternalFrame(new ReturnOperation(this).jif);
		}
		if (e.getSource() == jm71) {
			handleInternalFrame(new QueryFlight(this).jif);
		}
		if (e.getSource() == jm72) {
			handleInternalFrame(new ServiceJudge(this).jif);
		}
		if (e.getSource() == jm33) {
			handleInternalFrame(new DropFlight(this).jif);
		}
		if (e.getSource() == jm43) {
			handleInternalFrame(new SelectSuggestion(this).jif);
		}
		if (e.getSource() == jm12) {
			int n = JOptionPane.showConfirmDialog(null, "确定退出系统?", "提示",
					JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
			if (n == JOptionPane.YES_OPTION)
				mf.dispose();
		}
		if (e.getSource() == jm51) {
			JOptionPane.showMessageDialog(null,
					"VERSION 1.0 \n 302-1宿舍开发\n 作者:胡健,雷声,曹汪洋,邓聪聪", "关于",
					JOptionPane.INFORMATION_MESSAGE);
		}
		if (e.getSource() == jm41) {
			handleInternalFrame(new OrderSituation(this).jif);
		}
		if (e.getSource() == jm32) {
			handleInternalFrame(new AddFlight(this).jif);
		}
	}
}

⌨️ 快捷键说明

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