• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

activating menu items

 
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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the code to clear some fields on a GUI. Try adding it like this (course all the GUI variables are defined elsewhere:
[CODE]
btnClear = new Button("Clear");
btnClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
txtDRNum.setText("");
txtName.setText("");
lblErrMsg.setText("");
lstPart.select(-1);
lstToDept.select(-1);
lstFromDept.select(-1);
cbgNR.setSelectedCheckbox(ckbNew);
cbgReason.setSelectedCheckbox(ckbSPE1);
}
[\CODE]
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ronald,
I'm going to move this over to the Java Beginner's forum since it's not directly related to Certification Study.

------------------

Jane Griscti
Sun Certified Java 2 Programmer
"When ideas fail, words come in very handy" -- Goethe
reply
    Bookmark Topic Watch Topic
  • New Topic