JMenuBar disappears half the time when using a certain line of code?
I found this bug bizarre, but #java just redirected me to ##java on freenode and they didn't help and I even asked on Stack Overflow, so I am asking here.
When I have this code:
Code :
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
It makes my JMenuBar appear only sometimes(Is there a few times but then is gone another few times but no pattern either).
BUT, when I do this:
Code :
//frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
The JMenuBar is there 100% of the time.
My full code is here:
[Java] package main; import java.awt.event.ActionEvent; import java.awt.event.Actio - Pastebin.com
Thank you!
Re: JMenuBar disappears half the time when using a certain line of code?
Well in the frame Apia it says that the window change event is not guarenteed before the window is set to visible... so if your call to setExtendedState is before your call to setVisible, that would explain the strange behavior.
I am pretty sure that the layout manager deals with window events..
But do not quote me on that.
Re: JMenuBar disappears half the time when using a certain line of code?
Quote:
Originally Posted by
Tjstretch
Well in the frame Apia it says that the window change event is not guarenteed before the window is set to visible... so if your call to setExtendedState is before your call to setVisible, that would explain the strange behavior.
I am pretty sure that the layout manager deals with window events..
But do not quote me on that.
It works!
I tried it 10 times in a row, and everything worked, thank you!
BTW I'm quoting you :3