FileDocCategorySizeDatePackage
metrics.javaAPI DocExample2376Mon Mar 24 02:02:18 GMT 1997None

metrics

public class metrics extends Frame

Fields Summary
Constructors Summary
metrics()

        super ("metrics");
        setFont (new Font ("TimesRoman", Font.BOLD | Font.ITALIC, 48));
        resize (225, 175);
    
Methods Summary
public booleanhandleEvent(java.awt.Event e)

        if (e.id == Event.WINDOW_DESTROY) {
            dispose();
            System.exit (1);
        }
        return super.handleEvent (e);
    
public static voidmain(java.lang.String[] args)

        Frame f = new metrics ();
        f.show();
    
public voidpaint(java.awt.Graphics g)

        g.translate (insets().left, insets().top);
        FontMetrics fm = null;
        int ascent, descent, leading, width1, width2, height;
        String string1 = "O'Reilly";
        String string2 = "ÓReilly";
        int xPos = 25, yPos = 50;
        fm = g.getFontMetrics();
        ascent  = fm.getAscent();
        descent = fm.getDescent();
        leading = fm.getLeading();
        height  = fm.getHeight();
        width1  = fm.stringWidth (string1);
        width2  = fm.stringWidth (string2);
        g.drawString (string1, xPos, yPos);
        g.drawLine (xPos, yPos - ascent - leading,
                    xPos + width1, yPos - ascent - leading);
        g.drawLine (xPos, yPos - ascent,
                    xPos + width1, yPos - ascent);
        g.drawLine (xPos, yPos,
                    xPos + width1, yPos);
        g.drawLine (xPos, yPos + descent,
                    xPos + width1, yPos + descent);
        g.drawString (string2, xPos, yPos+height);
        g.drawLine (xPos, yPos - ascent - leading + height,
                    xPos + width2, yPos - ascent - leading + height);
        g.drawLine (xPos, yPos - ascent + height,
                    xPos + width2, yPos - ascent + height);
        g.drawLine (xPos, yPos + height,
                    xPos + width2, yPos + height);
        g.drawLine (xPos, yPos + descent + height,
                    xPos + width2, yPos + descent + height);

    
public voidupdate(java.awt.Graphics g)

        paint(g);