import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import javax.swing.JFrame;
public class A extends JFrame {
MenuBar mb = new MenuBar();
Menu m1 = new Menu("系统管理");
MenuItem m11 = new MenuItem("修改密码");
MenuItem m12 = new MenuItem("退出");
public A() {
this.setSize(300, 200);
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setDefaultCloseOperation(3);
this.setMenuBar(mb);
mb.add(m1);
m1.add(m11);
m1.add(m12);
m12.addActionListener(new B());
}
public static void main(String[] args) {
new A();
}
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class B implements ActionListener {
public void actionPerformed(ActionEvent e) {
A a = new A();
if(e.getSource() == a.m12) {
System.exit(0);
}
}
}
要怎么才能实现?