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

📄 mainwindow.java

📁 完成课程设计
💻 JAVA
字号:
package 客房管理;

import javax.swing.*;
import java.awt.event.*;

public class Mainwindow extends JFrame implements ActionListener 
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//定义
	JMenuBar jmbMain;
	JMenu jmSystem,jmSearch,jmAdd,jmCount,jmHelp;
	JMenuItem jmiLogin,jmiCancel,jmiExit,jmiSearchFullRoom,jmiSearchVoidRoom,jmiSearchName,jmiAdd,jmiDelete,jmiCircumstances,jmiRate,jmiIncome,jmiAbout,jmiCalculate,jmiLine;
	JLabel lbPicture;
	JPanel panel1;
	public Mainwindow()
	{
		super("客房管理");
		panel1=new JPanel();
		this.setContentPane(panel1);
		lbPicture=new JLabel(new ImageIcon(客房管理.Mainwindow.class.getResource("背景.jpg")));
		panel1.add(lbPicture);
		//主菜单
		jmbMain=new JMenuBar();
		jmSystem=new JMenu("系统");
		jmSearch=new JMenu("查询");
		jmAdd=new JMenu("登记");
		jmCount=new JMenu("统计");
		jmHelp=new JMenu("帮助");
		setJMenuBar(jmbMain);
		//添加主菜单
		jmbMain.add(jmSystem);
		jmbMain.add(jmSearch);
		jmbMain.add(jmAdd);
		jmbMain.add(jmCount);
		jmbMain.add(jmHelp);
		//系统子菜单
		jmiLogin=new JMenuItem("登陆");
		jmiLogin.addActionListener(this);
		jmSystem.add(jmiLogin);
		jmiCancel=new JMenuItem("注销");
		jmiCancel.addActionListener(this);
		jmiCancel.setEnabled(false);
		jmSystem.add(jmiCancel);
		jmiExit=new JMenuItem("退出");
		jmiExit.addActionListener(this);
		jmSystem.add(jmiExit);
		//查询子菜单
		
		jmiSearchFullRoom=new JMenuItem("查已住房");
		jmiSearchFullRoom.addActionListener(this);
		jmiSearchFullRoom.setEnabled(false);
		jmSearch.add(jmiSearchFullRoom);
		jmiSearchVoidRoom=new JMenuItem("查空房");
		jmiSearchVoidRoom.addActionListener(this);
		jmiSearchVoidRoom.setEnabled(false);
		jmSearch.add(jmiSearchVoidRoom);
		jmiSearchName=new JMenuItem("按名字或房号查");
		jmiSearchName.addActionListener(this);
		jmiSearchName.setEnabled(false);
		jmSearch.add(jmiSearchName);
		//jmiLine=new JMenuItem("************");
		//jmiLine.setEnabled(false);
		//jmSearch.add(jmiLine);
		jmiCalculate=new JMenuItem("结账");
		jmiCalculate.addActionListener(this);
		jmiCalculate.setEnabled(false);
		jmSearch.add(jmiCalculate);
		
		//登记子菜单
		jmiAdd=new JMenuItem("添加");
		jmiAdd.addActionListener(this);
		jmiAdd.setEnabled(false);
		jmAdd.add(jmiAdd);
		jmiDelete=new JMenuItem("删除");
		jmiDelete.addActionListener(this);
		jmiDelete.setEnabled(false);
		jmAdd.add(jmiDelete);
		//统计子菜单
		jmiCircumstances=new JMenuItem("入住情况");
		jmiCircumstances.addActionListener(this);
		jmiCircumstances.setEnabled(false);
		jmCount.add(jmiCircumstances);
		jmiRate=new JMenuItem("入住率");
		jmiRate.addActionListener(this);
		jmiRate.setEnabled(false);
		jmCount.add(jmiRate);
		jmiIncome=new JMenuItem("收入");
		jmiIncome.addActionListener(this);
		jmiIncome.setEnabled(false);
		jmCount.add(jmiIncome);
		//帮助子菜单
		jmiAbout=new JMenuItem("关于");
		jmiAbout.addActionListener(this);
		jmHelp.add(jmiAbout);
		
		
		
		//窗体属性
		setBounds(200,100,800,600);
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	}
	//菜单事件
	public void actionPerformed(ActionEvent ae)
	{
		//退出键
		if (ae.getSource()==jmiExit)
		{
			this.dispose();
			System.exit(0);
		}
		//登陆键
		else if(ae.getActionCommand()=="登陆")
		{
			this.dispose();
			Login login=new Login();
			login.setVisible(true);
		}
		//注销键
		else if(ae.getSource()==jmiCancel)
		{
			jmiCancel.setEnabled(false);
			jmiSearchFullRoom.setEnabled(false);
			jmiSearchVoidRoom.setEnabled(false);
			jmiSearchName.setEnabled(false);
			jmiAdd.setEnabled(false);
			jmiDelete.setEnabled(false);
			jmiCircumstances.setEnabled(false);
			jmiRate.setEnabled(false);
			jmiIncome.setEnabled(false);
			jmiCalculate.setEnabled(false);
		}
		//查已住房间键
		else if(ae.getSource()==jmiSearchFullRoom)
		{
			FullRoom fr=new FullRoom();
			fr.setVisible(true);
		}
		//查空房
		else if(ae.getSource()==jmiSearchVoidRoom)
		{
			VoidRoom vr=new VoidRoom();
			vr.setVisible(true);
		}
		//按名字或房号查
		else if(ae.getSource()==jmiSearchName)
		{
			SearchForName sfn=new SearchForName();
			sfn.setVisible(true);
		}
		//结账
		else if(ae.getSource()==jmiCalculate)
		{
			Calculate cal=new Calculate();
			cal.setVisible(true);
		}
		//添加
		else if(ae.getSource()==jmiAdd)
		{
			Add add=new Add();
			add.setVisible(true);
		}
		//删除
		else if(ae.getSource()==jmiDelete)
		{
			Delete delete=new Delete();
			delete.setVisible(true);
		}
		
		else if(ae.getSource()==jmiCircumstances)
		{
			StatisticsInto sta=new StatisticsInto();
			sta.setVisible(true);
		}
		
		else if(ae.getSource()==jmiRate)
		{
			Rate ra=new Rate();
			ra.setVisible(true);
		}
		//收入
		else if(ae.getSource()==jmiIncome)
		{
			InCome ic=new InCome();
			ic.setVisible(true);
		}
		//关于
		else if(ae.getSource()==jmiAbout)
		{
			About ab=new About();
			ab.setVisible(true);
		}
	}
	public static void main(String[] args) 
	{
			new Mainwindow();
	}

}

⌨️ 快捷键说明

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