Simple MenuBar question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Simple MenuBar question

  1. #1
    TVN1981 Guest

    Simple MenuBar question


    Hi,

    I am trying to create a class called MenubarItem that display some simple
    menu's ... But I don't why why when I use this class on my main program,
    nothing would show up. I am very new on the gui design stuffs. I think
    I
    am missing some components. But not sure. (*Note that I can make it work
    if I use everything in 1 class, but now I want to seperate the menu interface
    into a a different class and I can't get them work along)

    ----------------------------------------------------------------------------
    -----

    Here's my MenuBarItem class (on a seperate file called MenuBarItem.java)


    public class MenuBarInterface extends JMenu {
    private JMenu fileMenu;
    private JMenuItem openItem ;

    public MenuBarInterface()
    {
    fileMenu = new JMenu ("File");
    openItem = new JMenuItem ("Open") ;

    fileMenu.add(openItem);
    add(fileMenu);
    }
    }

    -----------------------------
    Here's my main program, it's called TheApp and inside the file TheApp.java

    public class TheApp extends JFrame {
    public TheApp()
    {
    super ("title");

    MenubarInterface bar = new MenuBarInterface();

    setSize(550,550), setVisible(true);
    }

    public static void main(String args[])
    {
    TheApp app = new TheApp();
    app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    }

    ----------------------------

    tia


  2. #2
    Paul Clapham Guest

    Re: Simple MenuBar question

    You don't have any code that tells your frame to use your MenuBarInterface.
    Have a look at this tutorial:

    http://java.sun.com/docs/books/tutor...ents/menu.html

    And have a look at several dozen similar tutorials:

    http://java.sun.com/docs/books/tutor...swing/TOC.html

    PC2

    "TVN1981" <cryptopo@hotmail.com> wrote in message
    news:3c307906$1@147.208.176.211...
    >
    > Hi,
    >
    > I am trying to create a class called MenubarItem that display some simple
    > menu's ... But I don't why why when I use this class on my main program,
    > nothing would show up. I am very new on the gui design stuffs.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center