JMenu doesn't appear until I hide or resize the JFrame

I have a GUI with JMenuBar , the problem is that sometimes JMenu does not appear until I resize or hide the JFrame . Can anybody help me?

+4
source share
2 answers

I had the same problem and solved it by setting JFrame visible AFTER the code for the menu. So, first create a JFrame , then add a JMenuBar and finally: frame.setVisible(true); (my frame is simply called a "frame", replace the "frame" with the name of your frame)

+5
source

Another less cute solution than @Marko's solution is to call frame.revalidate() after frame.setJMenuBar() -call.

+2
source

Source: https://habr.com/ru/post/1435691/


All Articles