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

📄 clientmainframe.java

📁 一个很详细的航空售票系统开发的例子
💻 JAVA
字号:
package com.tarena.abs.client;
import java.awt.*;
import javax.swing.*;

import sun.nio.cs.HistoricallyNamedCharset;

import java.awt.event.*;
import com.tarena.abs.model.*;

/**
 * 客户端主界面
 * @author new
 *
 */
public class ClientMainFrame extends JFrame implements ActionListener{
	/**
	 * 
	 */
	private static final long serialVersionUID = -6237134669488564901L;
	private JMenuBar jmb;
	private JMenu jm1,jm2;
	private JScrollPane center;
	private JTable table;
	
	public ClientMainFrame(){
		super("航班出票系统客户端 v1.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(1000,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");
						ClientMainClass.oos.writeObject(req);
						ClientMainClass.oos.flush();		
						System.exit(0);	
					} catch (Exception e1) {
						e1.printStackTrace();
					}
				}
			}
		});
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equals("登录/重登录")){
			ClientMainClass.init();
			new LoginFrame().showMe();
			this.dispose();
			return;
		}else if(e.getActionCommand().equals("设置连接参数")){
			new MyChangeIP(this);
			return;
		}else if(e.getActionCommand().equals("退出")){
			this.dispose();
			return;
		}else if(e.getActionCommand().equals("基本资料")){
			new MySelft();
			return;
		}else if(e.getActionCommand().equals("修改密码")){
			new ChangePasswd(this);
			return;
		}else if(e.getActionCommand().equals("历史记录")){
			new MyHistory(this);
			return;
		}
	}
}

⌨️ 快捷键说明

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