-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks