Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java remove JMenuBar

I have a frame containing a JMenuBar. If the users clicks the "Logout" MenuItem, I would remove all the frame's content and initialize it with other content. The issue is that if I call

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

the frame gets some other content but the JMenuBar from the previous "view" it's still here. How could I get rid of it?

like image 416
Teo Avatar asked Feb 20 '23 23:02

Teo


1 Answers

frame.setJMenuBar(null);  // this should do the job
like image 61
Andrew Thompson Avatar answered Mar 02 '23 22:03

Andrew Thompson