Java Reference
In-Depth Information
40.
searchItem.addActionListener(editorListener);
41.
}
42.
//
The next four methods do not yet do anything
43.
//
useful. The real code is supplied later.
44.
public void
openFile(){
45.
//
Code for loading a file has to go here.
46.
System.out.println("Menu item Load selected.");
47.
}
48.
49.
public void
saveFile(){
50.
//
Code for saving a file has to go here.
51.
System.out.println("Menu item Save selected.");
52.
}
53.
54.
public void
search(){
//
Code for searching has to go here.
55.
System.out.println("Menu item Search selected.");
56.
}
57.
58.
59.
public void
exitEditor(){
//
Code for leaving the editor has to go here.
60.
System.out.println("Menu item Exit selected.");
61.
62.
}
63.
}
File:
its/Dialogs/EditorListener.java
1.
package
its.Dialogs;
2.
3.
import
java.awt.event.ActionListener;
4.
import
java.awt.event.ActionEvent;
5.
import
javax.swing.JFrame;
6.
7.
public
class EditorListener
implements
ActionListener {
8.
9.
private
EditorSkeletonFrame editor;
10.
11.
public
EditorListener(EditorSkeletonFrame edi) {
12.
editor = edi;
}
13.
14.
15.
public void
actionPerformed(ActionEvent evt) {
String actionCommand = evt.getActionCommand();
16.
if
(actionCommand.equals("Load")){
17.
editor.openFile();
18.
}
19.
Search WWH ::
Custom Search