• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

help get menu items to work pleas

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have built a file menu with three buttons
New
Open
Save as
they show up fine but now how do i get them to work. this is for a program I'm trying to write that will open a blank file for NEW
open an existing file from a directory for OPEN and save a newly formed file in the SAVE AS function. Currently I add an action to the menu items with a simple item.addActionListener(this); call but I don't think that will work to get them to do what I want.
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps a code snippet would help everyone here. The basic process is to create the menu items, add action listeners to them and then set up if/else blocks within the actionPerformed(AvtionEvent e ){} method to deal with the individual menu items. It's from within these if/else statement that you would put the functionality as you described it above (or better yet, calls to methods that provide this funtionality). I'm sure you've got all this together, so perhaps a look at you code could reveal the problem that you are having.
Sean
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ron,
You are on the correct approach. If you are dealing with ASCII files and a TextArea I have included a simple code snippet to help you out.

Enjoy,
Manfred.
 
Ronald Pruitt
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just wanted to say Thank you for your help.
Ron
 
reply
    Bookmark Topic Watch Topic
  • New Topic