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

📄 clientmainframe.java

📁 航空售票系统的代码
💻 JAVA
字号:
package com.tarena.abs.client;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import com.tarena.abs.model.*;

/**
 * 客户端主界面
 * @author new
 *
 */

public class ClientMainFrame extends JFrame implements ActionListener{
	private JMenuBar jmb;
	private JMenu jm1,jm2;
	private JScrollPane center;
	private JTable table;
	
	public ClientMainFrame(){
		super("航班出票系统客户端 v8.0");
		jmb=new JMenuBar();
		jm1=new JMenu("连接设置");
		jm2=new JMenu("客户信息");
		JMenuItem jmi=null;
		jm1.add(jmi=new JMenuItem("登录/重登录"));jmi.addActionListener(this);
		jm1.add(jmi=new JMenuItem("设置连接参数"));jmi.addActionListener(this);
		jm1.add(jmi=new JMenuItem("退出"));jmi.addActionListener(this);
		
		jm2.add(jmi=new JMenuItem("基本资料"));jmi.addActionListener(this);
		jm2.add(jmi=new JMenuItem("修改密码"));jmi.addActionListener(this);
		jm2.add(jmi=new JMenuItem("历史记录"));jmi.addActionListener(this);
		
		jmb.add(jm1);
		jmb.add(jm2);
		
		center=new JScrollPane(new JPanel());
		this.setJMenuBar(jmb);                                                    //菜单
		this.add(new SeachFlightPanel(),BorderLayout.NORTH);         //航班查询模块
		this.add(center,BorderLayout.CENTER);                              //显示部分
		this.add(new AddOrderItemPanel(),BorderLayout.SOUTH);     //添加订单模块
	}
	
	public void setTable(JTable table){
		center.setViewportView(table);
		this.table=table;
		this.setVisible(true);
	}
	
	public JTable getTable(){
		return table;
	}
	
	public void showMe(){
		this.setSize(800,600);
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		this.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent arg0) {
				int select=JOptionPane.showConfirmDialog(ClientMainFrame.this,"退出程序将中断与服务器的连接,确定退出吗?",
						"确定退出程序吗?",JOptionPane.YES_NO_OPTION);
				if(select==JOptionPane.YES_OPTION){
					try {
						Request req=new Request("quit");
						req.setData("currentUser", ClientMainClass.currentUser.getName());
						ClientMainClass.oos.writeObject(req);
						ClientMainClass.oos.flush();		
						System.exit(0);	
					} catch (Exception e1) {
						e1.printStackTrace();
					}
				}
			}
		});
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equals("登录/重登录")){
			new LoginFrame().showMe();
			this.dispose();
			return;
		}else if(e.getActionCommand().equals("设置连接参数")){
			//待实现...
			return;
		}else if(e.getActionCommand().equals("退出")){
			int select=JOptionPane.showConfirmDialog(ClientMainFrame.this,"退出程序将中断与服务器的连接,确定退出吗?",
					"确定退出程序吗?",JOptionPane.YES_NO_OPTION);
			if(select==JOptionPane.YES_OPTION){
				try {
					Request req=new Request("quit");
					req.setData("currentUser", ClientMainClass.currentUser.getName());
					ClientMainClass.oos.writeObject(req);
					ClientMainClass.oos.flush();		
					System.exit(0);	
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
			return;
		}else if(e.getActionCommand().equals("基本资料")){
			Branch b = ClientMainClass.currentUser;
			StringBuffer sb = new StringBuffer();
			sb.append("营业网点名:"+b.getName()+"\n");
			sb.append("营业网点所在城市:"+b.getCity()+"\n");
			JOptionPane.showMessageDialog(this, sb);
			return;
		}else if(e.getActionCommand().equals("修改密码")){
			new ModifyAgentPasswdDialog(this).showMe();
			return;
		}else if(e.getActionCommand().equals("历史记录")){	
			//同服务器端查询网点订单
			return;
		}
	}
}

⌨️ 快捷键说明

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