File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes activating menu items Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "activating menu items" Watch "activating menu items" New topic
Author

activating menu items

Ronald Pruitt
Ranch Hand

Joined: Jan 15, 2001
Posts: 32
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.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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]

"JavaRanch, where the deer and the Certified play" - David O'Meara
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
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


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: activating menu items