Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Problem With Menu Bar Appear

Recommended Posts

I wrote this program which should have a menu bar. However, it does not appear.
heres the code

Code:

import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Desktop extends JFrame {	public static void main(String[] args) {  new Desktop();	}	public Desktop() {  super("Multiple Document Interface");  WindowUtilities.setNativeLookAndFeel();  addWindowListener(new ExitListener());  Container content = getContentPane();  //menu bar components  JMenuBar menu;  JMenu file;  JMenuItem newWindow;  JMenuItem close;  menu = new JMenuBar();  file = new JMenu("File");  newWindow = new JMenuItem("New Window");  close = new JMenuItem("Close");  menu.add(file);  file.add(newWindow);  file.add(close);  menu.setVisible(true);  content.setBackground(Color.white);  JDesktopPane desktop = new JDesktopPane();  desktop.setBackground(Color.white);  desktop.add(menu);  content.add(desktop, BorderLayout.CENTER);  setSize(600,600);  for(int i=1; i<6; i++) {        	JInternalFrame frame = new JInternalFrame(("Note " + i),true, true, true, true);        	frame.setLocation(i*50+10, i*50+10);        	frame.setSize(200, 150);        	frame.setBackground(Color.white);        	desktop.add(frame);        	frame.setVisible(true);  	frame.moveToFront();	  }	setVisible(true);	}}

Share this post


Link to post
Share on other sites

Hi,I'm very sorry. Buy the any Java beginner book. Writing on the forum is wasting you time. That is simple stuf. Buy book and start study. Come on...

Share this post


Link to post
Share on other sites

hey there! I think I get the problem here. You must have forgotten to set the menu bar. This might help:

menu.add(file);setJMenuBar(menu);
let me know if it worked. :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.