forked from Fuseken/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPutText.java
More file actions
29 lines (27 loc) · 950 Bytes
/
PutText.java
File metadata and controls
29 lines (27 loc) · 950 Bytes
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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PutText extends JPanel {
String[] type = { "Serif","SansSerif"};
int[] styles = { Font.PLAIN, Font.ITALIC, Font.BOLD,
Font.ITALIC + Font.BOLD };
String[] stylenames =
{ "Plain", "Italic", "Bold", "Bold & Italic" };
public void paint(Graphics g) {
for (int f = 0; f < type.length; f++) {
for (int s = 0; s < styles.length; s++) {
Font font = new Font(type[f], styles[s], 18);
g.setFont(font);
String name = type[f] + " " + stylenames[s];
g.drawString(name, 20, (f * 4 + s + 1) * 20);
}
}
}
public static void main(String[] a) {
JFrame f = new JFrame();
f.setContentPane(new PutText());
f.setSize(400,400);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}