-
Notifications
You must be signed in to change notification settings - Fork 0
/
fb.java
61 lines (61 loc) · 1.26 KB
/
fb.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
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code="fb" width=300 height=300></applet>*/
public class fb extends Applet implements ActionListener,AdjustmentListener,MouseMotionListener
{
List os,br;
String m="";
Scrollbar a,b;
public void init()
{
os=new List(2,true);
br=new List(2,false);
int w=300;
int h=300;
a=new Scrollbar(Scrollbar.VERTICAL,0,1,0,h);
b=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,w);
os.add("hi");
os.add("hi");
os.add("hi");
os.add("hi");
os.add("hi");
br.add("hello");
br.add("hello");
br.add("hello");
br.add("hello");
br.add("hello");
add(os);
add(br);
add(a);
add(b);
os.addActionListener(this);
br.addActionListener(this);
addMouseMotionListener(this);
a.addAdjustmentListener(this);
b.addAdjustmentListener(this);
}
public void actionPerformed(ActionEvent ae)
{
repaint();
}
public void mouseMoved(MouseEvent me){}
public void mouseDragged(MouseEvent me)
{
a.setValue(me.getY());
b.setValue(me.getX());
repaint();
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
repaint();
}
public void paint(Graphics g)
{
int t=os.getSelectedIndex();
m=m+os.getItem(t);
g.drawString(m,100,100);
m=""+a.getValue()+b.getValue();
showStatus(m);
}
}