4

我有一个包含 JMenuBar 的框架。如果用户单击“注销”菜单项,我将删除所有框架的内容并使用其他内容对其进行初始化。问题是,如果我打电话

parent.getContentPane().removeAll();
LoginActivity l = new LoginActivity(parent);
l.init();
parent.validate();

框架获得了一些其他内容,但来自前一个“视图”的 JMenuBar 仍然在这里。我怎么能摆脱它?

4

1 回答 1

8
frame.setJMenuBar(null);  // this should do the job
于 2012-03-31T08:05:58.537 回答