forked from nikhiljain-413/Hospital_ManageMent_System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowFonts4.java
More file actions
65 lines (61 loc) · 1.53 KB
/
Copy pathShowFonts4.java
File metadata and controls
65 lines (61 loc) · 1.53 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
//displaying the application of fonts
import java.applet.*;
import java.awt.*;
import java.awt.Font;
import java.awt.event.*;
public class ShowFonts4 extends Applet implements ItemListener
{
Choice ch,style,size;
String FontList[];
String msg,msg1,mssg;
int p;
Font f;
public void init()
{
ch=new Choice();
size=new Choice();
style=new Choice();
//f=new Font("Dialog",Font.PLAIN,12);
//setFont(f);
msg="";
msg1="";
mssg="Sample Font";
GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
FontList=ge.getAvailableFontFamilyNames();
for(int i=0;i<FontList.length;i++)
{
ch.add(FontList[i]);
}
for(int i=10;i<=72;i++)
{
size.add(Integer.toString(i));
}
style.add("PLAIN");
style.add("BOLD");
style.add("ITALIC");
add(ch);
add(size);
add(style);
ch.addItemListener(this);
size.addItemListener(this);
style.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
p=Integer.parseInt(size.getSelectedItem());
msg=ch.getSelectedItem();
msg1=style.getSelectedItem();
if(msg1.equals("PLAIN"))
f=new Font(ch.getSelectedItem(),Font.PLAIN,p);
if(msg1.equals("BOLD"))
f=new Font(ch.getSelectedItem(),Font.BOLD,p);
if(msg1.equals("ITALIC"))
f=new Font(ch.getSelectedItem(),Font.ITALIC,p);
repaint();
}
public void paint(Graphics g)
{
g.setFont(f);
g.drawString(mssg,80,50);
}
}