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

📄 mainframe.java

📁 长沙公交查询管理系统,主要实现对人员资料的管理以及车辆的分配路线。
💻 JAVA
字号:
/*此类负责主界面的界面规划与功能的实现*/
package pro;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class MainFrame extends JFrame implements ActionListener//实现监听器接口
{
	private Selebus sel;
	private CardLayout cl=new CardLayout();//设置卡片布局
	private JButton bntrl,bntdt,bnttq;
	private JPanel jp,jpsh,pnlc;
	private JLabel jla,jl2,jl3;
	private JLabel labPictrue;
	public PnlCha pnlCha=new PnlCha();
	public PnlXian pnlXian=new PnlXian();	
	private ImageIcon img ;
	private JButton btnCha,btnXian,btnZhan,btnIc,btnFa,btnJi,btnSi;
    private JButton btnGuan,btnLu,btnSou,butexit;
	private Container con;
    public MainFrame(int i)
    {   
		labPictrue=new JLabel(new ImageIcon("img/main.jpg"));
		labPictrue.setBounds(0,282,162,288);
		labPictrue.setBorder(BorderFactory.createLineBorder(Color.black));
    	pnlc=new JPanel();
       	bntdt=new JButton("查看地图",new ImageIcon("img/dh7.jpg"));
    	bnttq=new JButton("查看天气",new ImageIcon("img/tianqi.jpg"));
    	bntrl=new JButton("查看日历",new ImageIcon("img/1.jpg") );
     	pnlc.setBounds(163,51,700,540);
   
		
    	pnlc.setLayout(cl);
        jp=new JPanel();
		jpsh=new JPanel();

		jp.setLayout(null);
		
		btnGuan=new JButton("用户管理",new ImageIcon("img/dh8.jpg"));
		btnLu=new JButton("数据管理",new ImageIcon("img/dh1.jpg"));
		btnSou=new JButton("锁定系统",new ImageIcon("img/dh3.jpg"));
		butexit=new JButton("退出系统",new ImageIcon("img/exit.jpg"));
		jpsh.setLayout(new GridLayout(1,7));
		jpsh.add(btnGuan);
		jpsh.add(btnLu);
		
		jpsh.add(bntdt);
		jpsh.add(bnttq);
		jpsh.add(bntrl);
		jpsh.add(btnSou);
		jpsh.add(butexit);
		
		
	    img=new ImageIcon("img/cx_top.gif");
      
       	
       	jla=new JLabel(img);
       	jl3=new JLabel();
     	jl3.setBounds(162, 0, 162, 54);
       	
      	jla.setBounds(0, 0, 162, 24);
       	btnCha=new JButton(new ImageIcon("img/jt_gjcx.gif"));
        btnCha.setBounds(0, 22, 162, 30);
       	btnXian=new JButton(new ImageIcon("img/jt_xldq.gif"));
        btnXian.setBounds(0, 52, 162, 30);  
      	btnZhan=new JButton(new ImageIcon("img/jt_zddq.gif"));
       	btnZhan.setBounds(0, 82, 162, 30);  
       	btnIc=new JButton(new ImageIcon("img/jt_ic.gif"));
        btnIc.setBounds(0, 112, 162, 30);  
      	btnFa=new JButton(new ImageIcon("img/jt_zcfg.gif"));
      	btnFa.setBounds(0, 142, 162, 30);  
      	btnJi=new JButton(new ImageIcon("img/jt_zgjg.gif"));
        btnJi.setBounds(0, 172, 162, 30);  
        btnSi=new JButton(new ImageIcon("img/jt_gjgs.gif"));
        btnSi.setBounds(0, 202, 162, 30);  
        jl2=new JLabel(new ImageIcon("img/cx_bm.gif"));
       	jl2.setBounds(0, 264, 162, 25);

       	/*设置命令*/
       	btnCha.setActionCommand("btnCha");
       	btnFa.setActionCommand("btnFa");
       	btnIc.setActionCommand("btnIc");
       	btnSi.setActionCommand("btnSi");
       	btnZhan.setActionCommand("btnZhan");
       	btnXian.setActionCommand("btnXian");
       	btnJi.setActionCommand("btnJi");
       	btnSou.setActionCommand("btnSou");
       	butexit.setActionCommand("butexit");
       	bntrl.setActionCommand("bntrl");
       	btnLu.setActionCommand("btnLu");
       	btnGuan.setActionCommand("btnGuan");
       	bntdt.setActionCommand("bntdt");
       	bnttq.setActionCommand("bnttq");
       	
       		
       	/*注册监听器*/	
       	 btnCha.addActionListener(this);
       	 btnZhan.addActionListener(this);
       	 btnXian.addActionListener(this);
       	 btnSi.addActionListener(this);
       	 btnJi.addActionListener(this);
       	 btnIc.addActionListener(this);
       	 btnFa.addActionListener(this);
       	 btnSou.addActionListener(this);
       	 butexit.addActionListener(this);
       	 bntrl.addActionListener(this);
       	 btnLu.addActionListener(this);
       	 btnGuan.addActionListener(this);
       	 bntdt.addActionListener(this);
       	 bnttq.addActionListener(this);
       	 
       	 
       	pnlc.add(pnlCha,"pnlCha");
       //	pnlCha.setBounds();//
       	pnlc.add(pnlXian,"pnlXian");
       	pnlc.add(new PnlZhan(),"pnlZhan");
       	pnlc.add(new PnlIc(),"pnlIc");
       	pnlc.add(new PnlFa(),"pnlFa");
       	pnlc.add(new PnlJi(),"pnlJi");
       	pnlc.add(new PnlSi(),"pnlSi");
       	pnlc.add(new PnlDiTu(),"pnlDiTu");
        
       	
       	
       	con=this.getContentPane();
       	con.setLayout(null);
       	//con.setLayout(new BorderLayout());
       	
       	jp.add(jla);
       	jp.add(this.btnCha);
       	jp.add(this.btnXian);
        jp.add(this.btnZhan);
      	jp.add(this.btnIc);					
       	jp.add(this.btnFa);
       	jp.add(this.btnJi);
       	jp.add(this.btnSi);
       	jp.add(this.jl2);
      //	jp.add(this.jl3);
      	//jp.setBounds(0, 40, 162, 290);
      	jp.setBounds(0, 50, 162, 290);
     
     //	jpsh.setBounds(164, -5,622, 54);
        jpsh.setBounds(0, -5,785, 54);
     	con.add(labPictrue);
     	con.add(jp);
     	con.add(pnlc);
      	con.add(this.jpsh);
       	this.setSize(800,600);
       	this.setTitle("长沙公交查询管理系统");
       	this.setResizable(false);
       	this.setVisible(true);
       	
     
       		if(i==1)
       		{
       	       btnGuan.setEnabled(false);
       	       btnLu.setEnabled(false);
       	       btnSou.setEnabled(false);
       	       
       	    }
       	
     	
    }
    
    
    
    
    
    public void	actionPerformed(ActionEvent ae)
    {
    	String str=ae.getActionCommand();
    	if(str.equals("btnCha"))
    	{
    	
    		cl.show(this.pnlc,"pnlCha");//显示公交查询面板
    		
    	}
    	else if(str.equals("btnFa"))
    	{
    		cl.show(this.pnlc,"pnlFa");//显示政策法规面板
    	}
    	else if(str.equals("btnZhan"))
    	{
    		cl.show(this.pnlc,"pnlZhan");//显示站点大全面板
    	}
    	else if(str.equals("btnSi"))
    	{
    		cl.show(this.pnlc,"pnlSi");//显示公交公交公司面板
    	}
    	else if(str.equals("btnJi"))
    	{
    		cl.show(this.pnlc,"pnlJi");//显示主管机关面板
    	}
    	else if(str.equals("btnIc"))
    	{
    		cl.show(this.pnlc,"pnlIc");//显示公交IC卡面板
    	}
    	else if(str.equals("btnXian"))
    	{
    		cl.show(this.pnlc,"pnlXian");//显示线路大全的面板
    	}
    	else if(str.equals("bntdt"))
    	{
    	//	cl.show(this.pnlc,"pnlDiTu");
    	}
    	else if (str.equals("butexit"))
    	{
    		
    		new ExitFrame(this);//new 退出系统界面
    	}
    	else if(str.equals("btnSou"))
    	{
    	    //new LoginFrame(this); 	
    	    new Locked(this);
    	}
    	else if(str.equals("bntrl"))
    	{
    	RiliFrame rili=	new RiliFrame();//new 日历界面
    
        rili.setBounds(370,60,320,250);
        
    	}
    	else if(str.equals("btnLu"))
    	{
    		new NewFrame(this);//new 数据管理界面
    	}
    	else if(str.equals("btnGuan"))
    	{
    	      	new Addmins();//new 用户管理界面
    	}
    	else if(str.equals("btndt"))
    	{
    	    
    	}
    	else if(str.equals("bnttq"))
    	{
    		TianQiFrame tq=	new TianQiFrame();// new 天气预报的界面
    		tq.setBounds(200,60,375,318);
    			
    	}
    }
    
   public void windowDeactivated(WindowEvent we){}
   public void windowActivated(WindowEvent we){}
   public void windowDeiconified(WindowEvent we){}
   public void windowIconified(WindowEvent we){}
   public void windowClosed(WindowEvent we){}
   public void windowOpened(java.awt.event.WindowEvent we){}
   public void windowClosing(java.awt.event.WindowEvent we)
   {
   	try{
   	sel.st.close();
   	}
   	catch(java.sql.SQLException sqle){
   		sqle.printStackTrace();
   	}
   	DatabaseConnection.closeConnection();	
   	
    }
}

⌨️ 快捷键说明

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