Results 1 to 5 of 5
- 04-27-2011, 06:59 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 13
- Rep Power
- 0
JMenuBar not showing on a JFrame unless resized manually.
Hi.
I have searched for this, and found nothing similar.
I am using a JFrame that contains a JMenuBar.
The program works fine except that unless I resize the Frame manually, the MenuBar doesn't show.
Anyone know how to fix this?
Java Code:public class Move extends JFrame{ private JMenuBar Menubar; public static void main(String [] args) { new Move("Move"); } public Move (String name) { super(name); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.pack(); this.setSize(500,500); this.setLocation(600,500); this.setVisible(true); Menubar = new JMenuBar();//The main menubar setJMenuBar(Menubar); ... } }
- 04-27-2011, 07:32 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,068
- Blog Entries
- 3
- Rep Power
- 13
Try packing and doing all the stuff that displays it after setting the menu.
- 04-27-2011, 07:41 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 13
- Rep Power
- 0
- 04-27-2011, 07:48 AM #4
Member
- Join Date
- Apr 2011
- Posts
- 13
- Rep Power
- 0
Fixed!
I changed it to this.
Java Code:public static void main(String [] args) { Move mo = new Move("Move"); mo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mo.setVisible(true); } public Move (String name) { super(name); this.setSize(500,500); this.setLocation(600,500); ... }
- 04-27-2011, 08:50 AM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,068
- Blog Entries
- 3
- Rep Power
- 13
It looks like your fix just sets the visibility after adding the menu, I'm pretty sure that calls to lack, setSize and setVisible should be done after you have added everything to the frame. Either way, glad you solved it.
Similar Threads
-
JMenuBar error
By Tastosis in forum New To JavaReplies: 6Last Post: 03-02-2011, 12:55 PM -
Mutliple JMenuBar
By chyrl in forum AWT / SwingReplies: 10Last Post: 11-04-2010, 06:43 AM -
JPanel not showing up in JFrame
By rlindsey in forum AWT / SwingReplies: 2Last Post: 06-25-2010, 08:21 AM -
JMenubar option
By navishkumarb in forum New To JavaReplies: 3Last Post: 05-24-2010, 03:03 AM -
JFrame created but window contents not showing, othr threads keep waiting on the user
By FezKazi in forum AWT / SwingReplies: 1Last Post: 02-20-2009, 04:49 PM
Bookmarks