-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleFont.java
More file actions
65 lines (54 loc) · 1.09 KB
/
SampleFont.java
File metadata and controls
65 lines (54 loc) · 1.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
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class SampleFont extends Frame{
int next=0;
String msg;
Font f;
public SampleFont(){
f=new Font("Dialog",Font.PLAIN,15);
msg="DIALOG";
setFont(f);
addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent me){
next++;
switch(next) {
case 0:
f = new Font("Dialog", Font.PLAIN, 15);
msg = "Dialog";
break;
case 1:
f = new Font("DialogInput", Font.PLAIN, 55);
msg = "DialogInput";
break;
case 2:
f = new Font("SansSerif", Font.PLAIN, 55);
msg = "SansSerif";
break;
case 3:
f = new Font("Serif", Font.PLAIN, 55);
msg = "Serift";
break;
case 4:
f = new Font("Monospaced", Font.PLAIN, 55);
msg = "Monospaced";
break;
}
if(next == 4) next = -1;
setFont(f);
repaint();
}});
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}});
}
public void paint(Graphics g){
g.drawString(msg,10,130);
}
public static void main(String args[]){
SampleFont SF=new SampleFont();
SF.setSize(800,300);
SF.setVisible(true);
}
}