Results 1 to 4 of 4
  1. #1
    rsrana78 is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Default whats wrong with this and why it is not adding JMenuBar at JFrame???

    Java Code:
    class Frame
    {
         JFrame f=new JFrame("ABC");
    }
    class Menu
    {
        Frame obj=new Frame();
        JMenuBar b=new JMenuBar();
        obj.f.setJMenuBar(b); //there is no error but not showig the menubar
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,701
    Rep Power
    8

    Default Re: whats wrong with this and why it is not adding JMenuBar at JFrame???

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    MR bruto's Avatar
    MR bruto is offline Senior Member
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    130
    Rep Power
    0

    Default Re: whats wrong with this and why it is not adding JMenuBar at JFrame???

    i believe you should do
    Java Code:
    f.add(b)
    at least that's how its done with other components.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,701
    Rep Power
    8

    Default Re: whats wrong with this and why it is not adding JMenuBar at JFrame???

    Quote Originally Posted by MR bruto View Post
    i believe you should do
    Java Code:
    f.add(b)
    at least that's how its done with other components.
    This is not correct. Please read through the API and tutorials and be sure of your advice before you tell people the wrong thing. Recommended reading: How to Use Menus (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    But the OP has more basic problems (not using methods) than that, so he should fix that before trying to get a gui working.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. whats wrong with my GUI?
    By EscSequenceAlpha in forum New To Java
    Replies: 12
    Last Post: 05-31-2012, 08:20 PM
  2. I cant do this.Whats wrong?
    By gaston7eze in forum Java 2D
    Replies: 5
    Last Post: 05-30-2012, 12:34 AM
  3. Whats wrong with this?
    By Alkor in forum AWT / Swing
    Replies: 7
    Last Post: 04-03-2012, 05:49 AM
  4. Replies: 4
    Last Post: 04-27-2011, 07:50 AM
  5. Adding jmenubar inside jtabbed pane
    By suresh_m5a5@yahoo.co.in in forum AWT / Swing
    Replies: 1
    Last Post: 02-25-2011, 02:10 PM

Posting Permissions

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