🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #20080

Re: Simple sub-menu question?

#20080
From: Greg Hamer
Date: Wed, 29 Oct 1997 00:00
64 lines
1884 bytes
You need to keep an object of type MenuItem around long enough so you
can call
addActionListener on it. So change

 subMenuOpen.add( new MenuItem( "Phone Listing..." ));
to
MenuItem temp = new MenuItem("Phone Listing...");
temp.addActionListener(this);
subMenuOpen.add(temp);



Eric Advincula wrote:

>
>
> Can someone look at this code and tell me what needs to be done to add
> an addActionListener
> for the following sub-menu:
>
>
> <snip>
>
> Menu menuFile, subMenuOpen;
> MenuItem menuExit, menuSchedule;
>
> MenuBar menuBarMain;
>    .
>    .
>    .
> menuFile = new Menu( "File" );
>    .
>    .
>    .
> // File -> Open sub-menu selection
> 1)  subMenuOpen = new Menu( "Open" );
>
> // File -> Open -> Phone Listing sub-menu selection
> 2)  subMenuOpen.add( new MenuItem( "Phone Listing..." ));
> 3)  menuFile.add( subMenuOpen );
>
> // File -> Open -> Schedule sub-menu selection
> 4)  subMenuOpen.add( new MenuItem( "Schedule..." ));
> 5)  menuFile.add( subMenuOpen );
>
> menuFile.addSeparator(); // Separator between menu items
>
> // File -> Exit menu selection
> menuExit = new MenuItem( "Exit" );
> menuExit.addActionListener( this );
> menuFile.add( menuExit );
>
>
> menuBarMain.add( menuFile );
>
> for numbers 1-5 how do you add an action listener when the names of
> the submenus are the
> same.
>
> By the way I'm using 1.1 of the jdk
>
> Thanks in advance for any help
>
Technical Details
Message-ID: <34581DE6.374544B@borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34542DF3.8686E7C5@inreach.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,acfe0bdfac8d69a1
X-Google-Attributes: gidf74b3,public
From: Greg Hamer <ghamer@borland.com>
Subject: Re: Simple sub-menu question?
Date: 1997/10/29
Message-ID: <34581DE6.374544B@borland.com>
X-Deja-AN: 285895575
References: <34542DF3.8686E7C5@inreach.com>
X-Priority: 3 (Normal)
Organization: None
Newsgroups: borland.public.jbuilder.java.language