Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

activating menu items

 
Ronald Pruitt
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • 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.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • 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]
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic