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

📄 myremoveagent.java

📁 一套基于JAVA开发的完整版航空订票系统,代码简洁,适合JAVA初学者研究
💻 JAVA
字号:
package com.tarena.abs.server;import java.awt.*;import java.awt.event.*;import java.io.*;import javax.swing.*;import com.tarena.abs.dao.AgentDaoFromFile;public class MyRemoveAgent extends JDialog implements ActionListener{	private static final long serialVersionUID = -1756417676110895824L;	JLabel message,lab;	JTextField jtf;	JButton ok,cancel;	JPanel jp1,jp2,jp3;	public MyRemoveAgent(JFrame f){		super(f,"删除代理商",true);		message=new JLabel("删除代理商");		lab=new JLabel("代理商:");		jtf=new JTextField(8);		ok=new JButton("确定");		cancel=new JButton("取消");		jp1=new JPanel();		jp2=new JPanel();		jp3=new JPanel();		init();		addEventHandle();	}	private void init(){		jp1.add(message);		this.add(jp1,BorderLayout.NORTH);		jp2.add(lab);jp2.add(jtf);		this.add(jp2,BorderLayout.CENTER);		jp3.add(ok);jp3.add(cancel);		this.add(jp3,BorderLayout.SOUTH);	}	private void addEventHandle(){		ok.addActionListener(this);		cancel.addActionListener(this);	}	public void showMe(){		this.setSize(300,180);		this.setVisible(true);		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);	}	public void actionPerformed(ActionEvent e) {		String command=e.getActionCommand();		if(command.equals("确定")){			try {				AgentDaoFromFile f=new AgentDaoFromFile(new File("./agent.dat"));				boolean success=f.removeAgent(jtf.getText());				if(success){					JOptionPane.showMessageDialog(this,"删除成功!");					this.dispose();				}				else{					JOptionPane.showMessageDialog(this,"删除失败,可能无此代理商!");					this.dispose();				}			} catch (Exception e1) {				e1.printStackTrace();			}		}		else if(command.equals("取消")){			this.dispose();		}	}	}

⌨️ 快捷键说明

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