-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDisplayListener.java
67 lines (49 loc) · 1.3 KB
/
DisplayListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// The display listener, here all events are dispatched
// (c) Jimmy Larsson 1998
//
import java.awt.event.*;
public final class DisplayListener implements ActionListener, ItemListener
{
protected Hunter hunter;
protected Display display;
public DisplayListener (Hunter h, Display d)
{
hunter = h;
display = d;
}
// This catches:
// List double-click
// Button-click
// Textfield editing finished
// Menu choices
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action.equalsIgnoreCase("search"))
{
// SEARCH clicked
// Add case sensitivity here
DogSearchExp searchExp = new DogSearchExp (display.getSearchWords(), false);
hunter.startSearch(searchExp, display.getStartURL());
} else if (action.equalsIgnoreCase("results"))
{
// RESULTS clicked
hunter.dumpResults ();
} else if (action.equalsIgnoreCase("stop"))
{
// STOP clicked
hunter.stopSearch();
} else if (action.equalsIgnoreCase("quit"))
// gee, the user wants to quit =)
hunter.quit ();
}
// This catches:
// Checkbox
// CheckboxMenuItem
// Choice
// List (item selected)
public void itemStateChanged (ItemEvent e)
{
}
}