Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Create Menu and menu Itens Dynamic
Create Menu and menu Itens Dynamic [message #439231] Wed, 07 July 2004 18:17 Go to next message
Eclipse UserFriend
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 #439243 is a reply to message #439231] Thu, 08 July 2004 13:48 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
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...
>
>
>
>
>
Re: Create Menu and menu Itens Dynamic [message #439255 is a reply to message #439243] Thu, 08 July 2004 20:44 Go to previous message
Eclipse UserFriend
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...
> >
> >
> >
> >
> >
>
>
Previous Topic:No more callbacks
Next Topic:SWT Browser and open windows behavior
Goto Forum:
  


Current Time: Fri Mar 29 07:18:19 GMT 2024

Powered by FUDForum. Page generated in 0.03851 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top