package com.test;
import java.awt.BorderLayout;
import javax.swing.*;
import javax.activity.*;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Frame2 extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JPanel Jf;
public Frame2() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(borderLayout1);
this.setJMenuBar(jMenuBar1);
jMenu1.setText("测试");
jMenu1.addActionListener(new Frame2_jMenu1_actionAdapter(this));
jMenuBar1.add(jMenu1);
Jf=(JPanel)this.getContentPane();
Jf.add(new Welcome());
Jf.updateUI();
// Jf.setLayout(null);
this.setSize(400,300);
this.setVisible(true);
}
public static void main(String args[]){
Frame2 F =new Frame2();
}
public void jMenu1_actionPerformed(ActionEvent e) {//这个竟然不起作用,点“测试”菜单没有任何反映
Jf.removeAll();
Jf.add(new FrmUp());
Jf.updateUI();
}
}
class Frame2_jMenu1_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jMenu1_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenu1_actionPerformed(e);
}
}
点“测试”菜单没有任何反映,请帮我看下,谢谢1