🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Simple sub-menu question?

#20135
From: Eric Advincula
Date: Sun, 26 Oct 1997 00:00
156 lines
4188 bytes

--------------4E57087818C0E421FE47608C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Can someone look at this code and tell me what needs to be done to add
an addActionListener
for the following sub-menu:

In an ordinary menu its easy:

Menu menuHelp;
MenuItem menuAbout;

MenuBar menuBarMain;
     .
     .
     .
menuHelp = new Menu( "Help" );
menuAbout = new MenuItem( "About..." );
menuHelp.add( menuAbout );
menuAbout.addActionListener( this );
menuBarMain.add( menuHelp );
      .
      .
      .
if (event.getSource() == menuAbout ) {
 aboutDlg.show();
}


/*******************************************/

But for sub-menus its a little different:


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


--------------4E57087818C0E421FE47608C
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Can someone look at this code and tell me what needs to be done to add
an addActionListener
<BR>for the following sub-menu:

<P><B><U>In an ordinary menu its easy:</U></B>

<P>Menu menuHelp;
<BR>MenuItem menuAbout;

<P>MenuBar menuBarMain;
<BR>&nbsp;&nbsp;&nbsp;&nbsp; .
<BR>&nbsp;&nbsp;&nbsp;&nbsp; .
<BR>&nbsp;&nbsp;&nbsp;&nbsp; .
<BR>menuHelp = new Menu( "Help" );
<BR>menuAbout = new MenuItem( "About..." );
<BR>menuHelp.add( menuAbout );
<BR>menuAbout.addActionListener( this );
<BR>menuBarMain.add( menuHelp );
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .
<BR>if (event.getSource() == menuAbout ) {
<BR>&nbsp;aboutDlg.show();
<BR>}
<BR>&nbsp;

<P>/*******************************************/

<P><B><U>But for sub-menus its a little different:</U></B>
<BR>&nbsp;

<P>Menu menuFile, subMenuOpen;
<BR>MenuItem menuExit, menuSchedule;

<P>MenuBar menuBarMain;
<BR>&nbsp;&nbsp; .
<BR>&nbsp;&nbsp; .
<BR>&nbsp;&nbsp; .
<BR>menuFile = new Menu( "File" );
<BR>&nbsp;&nbsp; .
<BR>&nbsp;&nbsp; .
<BR>&nbsp;&nbsp; .
<BR>// File -> Open sub-menu selection
<BR>1)&nbsp; subMenuOpen = new Menu( "Open" );

<P>// File -> Open -> Phone Listing sub-menu selection
<BR>2)&nbsp; subMenuOpen.add( new MenuItem( "Phone Listing..." ));
<BR>3)&nbsp; menuFile.add( subMenuOpen );

<P>// File -> Open -> Schedule sub-menu selection
<BR>4)&nbsp; subMenuOpen.add( new MenuItem( "Schedule..." ));
<BR>5)&nbsp; menuFile.add( subMenuOpen );

<P>menuFile.addSeparator(); // Separator between menu items

<P>// File -> Exit menu selection
<BR>menuExit = new MenuItem( "Exit" );
<BR>menuExit.addActionListener( this );
<BR>menuFile.add( menuExit );
<BR>&nbsp;

<P>menuBarMain.add( menuFile );

<P>for numbers 1-5 how do you add an action listener when the names of
the submenus are the
<BR>same.

<P>By the way I'm using 1.1 of the jdk

<P>Thanks in advance for any help
<BR>&nbsp;</HTML>

--------------4E57087818C0E421FE47608C--
Technical Details
Message-ID: <34542DF3.8686E7C5@inreach.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,acfe0bdfac8d69a1,start
X-Google-Attributes: gidf74b3,public
From: Eric Advincula <rsystems@inreach.com>
Subject: Simple sub-menu question?
Date: 1997/10/26
Message-ID: <34542DF3.8686E7C5@inreach.com>
X-Deja-AN: 285263194
Organization: STS/Ceridian
Newsgroups: borland.public.jbuilder.java.language