Create Menu and menu Itens Dynamic [message #439231] |
Wed, 07 July 2004 18:17 |
Eclipse User |
|
|
|
Originally posted by: tchebraga.msn.com
Hi!
Any one can help me? Please
I need to create a dynamic menus at runtime. The captions of menus are
stored is a array of string, kind
String menus[] = {"File","Edit","Help"}
How can I do to create the menus File, Edit and Help at runtime?
Please nay help...
|
|
|
|
Re: Create Menu and menu Itens Dynamic [message #439255 is a reply to message #439243] |
Thu, 08 July 2004 20:44 |
Eclipse User |
|
|
|
Originally posted by: tchebraga.msn.com
ty
I has resolved, based in same sample... :-(
public class Teste {
public static void main(String[] args)
{
final Display display = new Display ();
Shell shell = new Shell (display);
final Menu menuzao = new Menu(shell,SWT.BAR);
shell.setMenuBar(menuzao);
String menus[] = {"File", "Edit", "Help"};
String comandos[] = {"00;mnuNew;New", "00;mnuOpen;Open", "01;mnuCut;Cut",
"02;mnuHelp;Help"};
for (int i=0; i<menus.length; i++)
{
MenuItem menuItem = new MenuItem (menuzao, SWT.CASCADE);
menuItem.setText (menus [i].toString());
Menu menu = new Menu (shell,SWT.DROP_DOWN);
menuItem.setMenu(menu);
for (int j=0; j<comandos.length;j++)
{
if (Integer.parseInt(comandos[j].toString().substring(0,2))== i)
{
MenuItem comando = new MenuItem(menu,SWT.PUSH);
comando.setText(comandos[j].toString());
}
}
}
shell.setSize (300, 300);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
"Steve Northover" <steve_northover@ca.ibm.com> escreveu na mensagem
news:ccjj99$ilo$1@eclipse.org...
> Create and configure instances of Menu and MenuItem?
>
>
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet97.html
>
> "Luis Carlos Braga" <tchebraga@msn.com> wrote in message
> news:cchemg$gs$1@eclipse.org...
> > Hi!
> >
> > Any one can help me? Please
> >
> > I need to create a dynamic menus at runtime. The captions of menus are
> > stored is a array of string, kind
> >
> > String menus[] = {"File","Edit","Help"}
> >
> > How can I do to create the menus File, Edit and Help at runtime?
> >
> > Please nay help...
> >
> >
> >
> >
> >
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03851 seconds