Menu

Hello

I have such idea :

I have a menu where I can choose "FILE" or "RUN"

Than in menu "FILE" I can choose from two menuItems "exit" or "read" . And then I want that if I choose "read" the new menu "TYPE" would appear.

Maybe somebody can help me ?

I would very appreciate each idea.

Now I have such code :

.........................

privatevoid CreateMenu(){

Menu fileMenu =new Menu("FILE");

Menu runMenu =new Menu("RUN");

//fileMenu

fileMenu.addActionListener(this);

exit=new MenuItem("Exit");

fRead =new MenuItem("Read");

fileMenu.add(exit);

fileMenu.add(fRead);

//runMenu

runMenu.addActionListener(this);

run =new MenuItem("run");

runMenu.add(run);

MenuBar mBar =new MenuBar();

mBar.add(fileMenu);

mBar.add(runMenu);

setMenuBar(mBar);

}

publicvoid actionPerformed(ActionEvent e){

command = e.getActionCommand();

if (command.equals("Exit")){

dispose();

System.exit(0);

}

........

}

Thank you.

[1968 byte] By [Micky01] at [2007-9-26 3:08:45]
# 1
you can always create the whole menubar new with menus and menu items in the places you want to have them right now. You can keep your menuitems (or your menues if you don't change them) to keep Listeners and other references.
arcosh at 2007-6-29 11:13:52 > top of Java-index,Archived Forums,Java Programming...
# 2
Sorry I didn't understand you...
Micky01 at 2007-6-29 11:13:52 > top of Java-index,Archived Forums,Java Programming...
# 3

MenuBar mb;

MenuItem m1,m2,m3,m4;

//in the constructor

m1=new ManuItem(....);

m2=.......

public void designMenu(args defining what menus you want to be visible where)

{

mb=new MenuBar();

if (func(args)==1) //or any other checking method

{

Menu mn=new Menu(...);

mn.add(m1);

mn.add(m2);

mb.add(mn);

}

if (func(args)==2)

{

Menu mn1=new Menu(..);

mn1.add(m3);

Menu mn2=new Menu(..);

mn2.add(m1);

mb.add(mn1);

mb.add(mn2);

}

yourframe.setMenu(mb) (whatever the tsetmenu funcion is

I hope this is more understandable

arcosh at 2007-6-29 11:13:52 > top of Java-index,Archived Forums,Java Programming...
# 4
Thank you for idea , i'll try it later
Micky01 at 2007-6-29 11:13:52 > top of Java-index,Archived Forums,Java Programming...