Results 1 to 2 of 2
  1. #1
    ElvisMachuca is offline Member
    Join Date
    Jan 2013
    Posts
    32
    Rep Power
    0

    Default I started a JApplet but when I add JMenuBar the bar and menus don't show up

    import javax.swing.JApplet;
    import javax.swing.JMenuBar;
    import javax.swing.JMenu;

    public class HelloWorldWithMenuBar extends JApplet {

    private JMenuBar menuBar = null;
    private JMenu fileMenu = null;

    public void init(){

    menuBar = new JMenuBar();

    fileMenu = new JMenu("File");

    menuBar.add(fileMenu):

    setJMenuBar(menuBar);

    }
    }

    when I run this code, the JMenuBar and JMenu don't show up on the japplet.

    There is no exception errors or anything, what am I missing?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: I started a JApplet but when I add JMenuBar the bar and menus don't show up

    When I corrected your code by changing a ":" to a ";", it worked fine more me.

    Here's your code posted with [code] [/code] around it so that it retains its formatting:

    Java Code:
    import javax.swing.JApplet;
    import javax.swing.JMenuBar;
    import javax.swing.JMenu;
    
    public class HelloWorldWithMenuBar extends JApplet {
       private JMenuBar menuBar = null;
       private JMenu fileMenu = null;
    
       public void init() {
          menuBar = new JMenuBar();
          fileMenu = new JMenu("File");
          menuBar.add(fileMenu); // *** this line was corrected ***
          setJMenuBar(menuBar);
       }
    }

Similar Threads

  1. JApplet works in eclipse but refuses to show online
    By Reskaillev in forum New To Java
    Replies: 14
    Last Post: 09-10-2011, 01:36 PM
  2. JMenuBar error
    By Tastosis in forum New To Java
    Replies: 6
    Last Post: 03-02-2011, 11:55 AM
  3. Mutliple JMenuBar
    By chyrl in forum AWT / Swing
    Replies: 10
    Last Post: 11-04-2010, 05:43 AM
  4. JMenubar option
    By navishkumarb in forum New To Java
    Replies: 3
    Last Post: 05-24-2010, 02:03 AM
  5. JFrame to JApplet or JApplet to JApplet
    By ramesh.8189 in forum AWT / Swing
    Replies: 13
    Last Post: 02-08-2009, 06:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •