home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-02-22 | 1.0 KB | 41 lines |
- import java.awt.*;
- import java.applet.*;
-
- public class FontApplet2 extends Applet
- {
- TextField textField;
-
- public void init()
- {
- textField = new TextField(10);
- add(textField);
- textField.setText("32");
- }
-
- public void paint(Graphics g)
- {
- String s = textField.getText();
- int height = Integer.parseInt(s);
-
- Font font = new Font("TimesRoman", Font.PLAIN, height);
- g.setFont(font);
- FontMetrics fontMetrics = g.getFontMetrics(font);
- height = fontMetrics.getHeight();
-
- int row = 80;
- g.drawString("This is the first line.", 70, row);
- row += height;
- g.drawString("This is the second line.", 70, row);
- row += height;
- g.drawString("This is the third line.", 70, row);
- row += height;
- g.drawString("This is the fourth line.", 70, row);
- }
-
- public boolean action(Event event, Object arg)
- {
- repaint();
- return true;
- }
- }
-