Creating menus at runtime

B

Braga

Hi.
I whant create my menus (Jmenu) from array aMenus ={"File","Edit",
"Help"}
and menu items (JMenuItem) from array aItems =
{"File,New","File,Save","File,Exit","Edit,Paste", "Edit,Cut",
"Help,Help"}

my big problem I DON'T KNOW HOW TO DO to create menus at runtime...
aney help please..
 
T

Thomas Kellerer

Braga said:
Hi.
I whant create my menus (Jmenu) from array aMenus ={"File","Edit",
"Help"}
and menu items (JMenuItem) from array aItems =
{"File,New","File,Save","File,Exit","Edit,Paste", "Edit,Cut",
"Help,Help"}

my big problem I DON'T KNOW HOW TO DO to create menus at runtime...
aney help please..

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JMenu.html

tells me I can create a JMenu like this:

JMenu menu = new JMenu("File");

There is even more, it also tells me that I can add a JMenuItem. Wow!

JMenuItem item = new JMenuItem("New");
menu.add(item);

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JMenuItem.html
http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html

If you want to become a good programmer, learn to read the documentation
first.
 
D

David Alex Lamb

Hi.
I whant create my menus (Jmenu) from array aMenus ={"File","Edit",
"Help"}
and menu items (JMenuItem) from array aItems =
{"File,New","File,Save","File,Exit","Edit,Paste", "Edit,Cut",
"Help,Help"}

my big problem I DON'T KNOW HOW TO DO to create menus at runtime...
aney help please..

This doesn't directly help the OP but...
I've been working on a package for automating menu construction, based on an
idea of Roedy's, whose current state is found at
http://www.cs.queensu.ca/home/dalam...menu/package-summary.html#package_description

I'd appreciate knowing if there's someone willing to be create or convert a
small application or applet for which automated menu creation might be useful.
 
Y

Yu SONG

Braga said:
Hi.
I whant create my menus (Jmenu) from array aMenus ={"File","Edit",
"Help"}
and menu items (JMenuItem) from array aItems =
{"File,New","File,Save","File,Exit","Edit,Paste", "Edit,Cut",
"Help,Help"}

my big problem I DON'T KNOW HOW TO DO to create menus at runtime...
aney help please..

Have a look at API.

Also you may need to consider thread issues (i.e. event-dispatching
thread) for "changing" GUI.

--
Song

/* E-mail.c */
#define User "Yu.Song"
#define Warwick "warwick.ac.uk"
int main() {
printf("Yu Song's E-mail: %s@%s", User, Warwick);
return 0;}

Further Info. : http://www.dcs.warwick.ac.uk/~esubbn/
_______________________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top