Computer Science Canada JMenuBar won't show up on my JFrame |
Author: | Bo0sT [ Sat Apr 25, 2009 12:17 pm ] |
Post subject: | JMenuBar won't show up on my JFrame |
So I made a subclass of JFrame and i'm using it as the entry point to my program. So far all I have on it is a JMenuBar and a subclass of Canvas. The JMenuBar has one JMenu on it and the JMenu has four JMenuItems. So I added the JMenuBar using setJMenuBar(JMenuBar) and everything worked nicely. Then I changed the look and feel to getSystemLookAndFeelClassName() and now only the Canvas shows up but the JMenuBar doesn't. I'm thinking it's because the Canvas is from java.awt and the JMenuBar is javax.swing, so the look and feel effects them diffrently, i'm not sure if i'm right but if I am how could I work around this? If i'm not then what's wrong and how do I fix it? |
Author: | Dark [ Sun Apr 26, 2009 10:26 am ] |
Post subject: | RE:JMenuBar won\'t show up on my JFrame |
Hard to say because you don't have a code snippet posted... but have you tried .setVisible(true); for the JFrame? that could help. I've never used Canvas but post your GUI code and I might be able to help. |
Author: | Bo0sT [ Sun Apr 26, 2009 5:36 pm ] | ||
Post subject: | Re: JMenuBar won't show up on my JFrame | ||
I made my description so long so that I wouldn't have to post a code snippet. I'll remake a sample though, so that my code isn't on the internet and I don't get accused of plagurism. It's basically what I explained
ok here is a sample of my code, this is a watered down version of it, of just what is giving me problems, there are more bells and whistles on the original. Also, while I was writing this I found that if i resize the screen, everything shows up like it's supose to. I think I can use that to solve my problem but if anyone has anything better plz link me back |
Author: | Dark [ Tue Apr 28, 2009 2:31 pm ] | ||||
Post subject: | RE:JMenuBar won\'t show up on my JFrame | ||||
Put
at the end of your constructor public CharacterMaker(), right under
Always have your setVisible(true); as the last line of code in constructor methods such as this one, so after the compiler executes your code, it will set your JFrame to visible. Otherwise, in your case for example, it will be set to visible but then add the menu after. So put setVisible at the end. Hope that helps |