Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: JMenuBar disappears half the time when using a certain line of code?

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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:
    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:
    //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!


  2. #2
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default 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.

  3. The Following User Says Thank You to Tjstretch For This Useful Post:

    !Marcus (December 26th, 2011)

  4. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: JMenuBar disappears half the time when using a certain line of code?

    Quote Originally Posted by Tjstretch View Post
    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

Similar Threads

  1. Replies: 10
    Last Post: September 16th, 2011, 07:49 PM
  2. Replies: 33
    Last Post: May 25th, 2011, 06:59 AM
  3. Square Game (a half solved, please help with the rest!!!)
    By LadyBelka in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 23rd, 2011, 04:42 PM
  4. Help with a line of my code.
    By Miical94 in forum Object Oriented Programming
    Replies: 1
    Last Post: March 7th, 2011, 11:00 AM
  5. loop and a half
    By Brain_Child in forum Loops & Control Statements
    Replies: 2
    Last Post: January 22nd, 2010, 03:52 AM

Tags for this Thread