-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind.java
122 lines (115 loc) · 3.27 KB
/
Find.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import java.awt.*;
import java.awt.event.*;
class Find extends Dialog implements ActionListener
{
Label l1;
TextField t1;
Checkbox c1,c2,c3;
CheckboxGroup cg;
MainMenu k;
int t= -1;
int count=0,stay=0;
Button b1,b2;
String str="",str2="",str1="";
public Find(MainMenu p,String tt,boolean rr)
{
super(p,tt,rr);
k=p;
setLayout(new FlowLayout());
l1=new Label("Find Text");
cg= new CheckboxGroup();
c1= new Checkbox("Match Case",false);
c2= new Checkbox("Up",cg,false);
c3= new Checkbox("Down",cg,true);
b1= new Button("Find Next");
b2= new Button("Cancel");
t1= new TextField(15);
add(l1);
add(t1);
add(b1);
add(b2);
add(c1);
add(c2);
add(c3);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if(str.equals("Find Next"))
{
if(c3.getState()==true)
{
//count++;
stay++;
char cmp='\n';
str1=k.t1.getText();
str2=t1.getText();
int last= str1.length();
int startp=str1.indexOf(str2);
t= str1.indexOf(str2,t+1);
/* //System.out.println(t1.getText());
int i;
for(i=0;i<str1.lastIndexOf(str2);t++)
{
//t= str1.indexOf(str2,t+1);
/*if(count%2==1)
{
t= str1.indexOf(str2,t+1);
System.out.println("T value is "+t);
if(t<0)
{}
else
{
k.t1.select(t,t+str2.length());
k.setVisible(true);
}
}
else if(count%2==0)
{
t= str1.indexOf(str2,t+1);
System.out.println("T value is "+t);
if(t<0)
{}
else
{
k.t1.select(t,t+str2.length());
k.setVisible(true);
}
}
}*/
if(t<0)
{}
else
{
k.t1.select(t,t+str2.length());
k.setVisible(true);
}
}
else if(c2.getState()==true)
{
int z= k.t1.getText().length();
str1=k.t1.getText();
str2=t1.getText();
z=str1.substring(0,z).lastIndexOf(str2);
k.t1.select(z,z+str2.length());
k.setVisible(true);
str1=str1.substring(0,z);
}
else if(c3.getState()==true)
{
int z= k.t1.getText().length();
str1=k.t1.getText().toLowerCase();
str2=t1.getText().toLowerCase();
z=str1.substring(0,z).lastIndexOf(str2);
k.t1.select(z,z+str2.length());
k.setVisible(true);
}
}
else if(str.equals("Cancel"))
{
this.dispose();
}
}
}