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

📄 bookingsystemgui.java

📁 飞机自动订票系统有JAVA SWING 实现gui 主要包括booking system seats, class 等
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BookingSystemGUI extends JFrame{
	private static final int WIDTH =500;
	private static final int HEIGHT=200;
	private EconomyClass myEconomyClass;
	private FirstClass myFirstClass;
	private EconomyClass myEconomyClass1;
	public BookingSystemGUI(EconomyClass myEconomyClass,EconomyClass myEconomyClass1,FirstClass myFirstClass)
	{
		this.myEconomyClass=myEconomyClass;
		this.myEconomyClass1=myEconomyClass1;
		this.myFirstClass=myFirstClass;
		Container con=getContentPane();
		Toolkit kit=Toolkit.getDefaultToolkit();
		setSize(WIDTH,HEIGHT);
		setTitle("Booking System");
		Dimension screensize=kit.getScreenSize();
		int width=screensize.width;
		int height=screensize.height;
		int x=(width-WIDTH)/2;
		int y=(height-HEIGHT)/2;
		setLocation(x,y);
		setResizable(true);
		ButtonPanel panel1=new ButtonPanel(this);//transfer JFrame object to actionlisterner
		con.add(panel1,BorderLayout.CENTER);
		LabelPanel panel2=new LabelPanel();
		con.add(panel2,BorderLayout.NORTH);
	}
	public class ButtonPanel extends JPanel
	{
		private JButton button1;
		private JButton button2;
		private JButton button3;
		private JFrame parFrame;
		public ButtonPanel(JFrame frame)
		{
			parFrame=frame;
			button1=new JButton("flight");
			add(button1);
			button1.addActionListener(new MakeNewFlightAction());
			button2=new JButton("passenger");
			add(button2);
			button2.addActionListener(new MakeNewPassengerAction());
			button3=new JButton("aircraft");
			add(button3);
			button3.addActionListener(new MakeNewAircraftAction());
		}
		public class MakeNewFlightAction implements ActionListener
		{
			public void actionPerformed(ActionEvent event)
			{
				FlightGUI subFrame=new FlightGUI(parFrame,myEconomyClass,myEconomyClass1,myFirstClass);//transfer first frame to the second frame
				subFrame.setVisible(true);
				parFrame.setVisible(false);
			}
		}
		public class MakeNewPassengerAction implements ActionListener
		{
			public void actionPerformed(ActionEvent event)
			{
				PassengerGUI subFrame=new PassengerGUI(parFrame,myEconomyClass,myEconomyClass1,myFirstClass);//transfer first frame to the second frame
				subFrame.setVisible(true);
				parFrame.setVisible(false);
			}
		}
		public class MakeNewAircraftAction implements ActionListener
		{
			public void actionPerformed(ActionEvent event)
			{
				AircraftGUI2 subFrame=new AircraftGUI2(parFrame,myEconomyClass,myEconomyClass1,myFirstClass);//transfer first frame to the second frame
				subFrame.setVisible(true);
				parFrame.setVisible(false);
			}
		}
	}
	public class LabelPanel extends JPanel
	{
		private JLabel label1;
		public LabelPanel()
		{
			label1=new JLabel("Welcome to Booking System please select the option");
			Font stringFont=new Font("SansSerif",Font.BOLD+Font.ITALIC,18);
			label1.setFont(stringFont);
			add(label1);
		}
	}
}

⌨️ 快捷键说明

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