-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRB17.java
More file actions
111 lines (111 loc) · 2.09 KB
/
Copy pathRB17.java
File metadata and controls
111 lines (111 loc) · 2.09 KB
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
// APPLETS //
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class RB17 extends Applet implements KeyListener , MouseListener
{
char d;
String s,c;
int i,j,k,x,y;
public void init()
{
i = k = 0;
s = c = "";
addKeyListener(this);
addMouseListener(this);
}
public void mousePressed(MouseEvent me)
{
x = me.getX();
y = me.getY();
showStatus("MOUSE PRESSED at " + x + " , " + y);
}
public void mouseReleased(MouseEvent me)
{
x = me.getX();
y = me.getY();
showStatus("MOUSE RELEASED at " + x + " , " + y);
}
public void mouseClicked(MouseEvent me)
{
x = me.getX();
y = me.getY();
showStatus("MOUSE CLICKED at " + x + " , " + y);
if((x >= 10 && x <= 100) && (y >= 10 && y <= 30))
{
k = 1;
}
if((x >= 110 && x <= 200) && (y >= 10 && y <= 30))
{
k = 0;
}
if((x >= 210 && x <= 300) && (y >= 10 && y <= 30))
{
k = 2;
}
}
public void mouseEntered(MouseEvent me)
{
showStatus("MOUSE ENTERED");
}
public void mouseExited(MouseEvent me)
{
showStatus("MOUSE EXITED");
}
public void keyPressed(KeyEvent ke)
{
showStatus("KEY PRESSED");
}
public void keyReleased(KeyEvent ke)
{
showStatus("KEY RELEASED");
}
public void keyTyped(KeyEvent ke)
{
c = "";
d = ke.getKeyChar();
c = c + d;
if(k == 2)
{
if((s.equals("")) || (s.charAt(s.length() - 1) == ' '))
{
c = c.toUpperCase();
}
else
{
c = c.toLowerCase();
}
}
if(k == 1)
{
c = c.toUpperCase();
}
if(k == 0)
{
c = c.toLowerCase();
}
s = s + c;
i = s.length() / 100;
repaint(50,50 + i * 20,1250,30);
if(i == 0)
{
j = 0;
}
else
{
j = 100 * i - 1;
}
}
public void paint(Graphics g)
{
g.setColor(Color.orange);
g.fillRect(10,10,90,30);
g.fillRect(110,10,90,30);
g.fillRect(210,10,90,30);
g.setColor(Color.black);
g.drawString("UPPER CASE" , 15 , 30);
g.drawString("lower case" , 124 , 30);
g.drawString("Title Case" , 224 , 30);
g.drawString(s.substring(j),70,50 + i * 20 + 15);
}
}