FileDocCategorySizeDatePackage
HitMe.javaAPI DocExample1098Mon Apr 05 10:30:26 BST 1999None

HitMe

public class HitMe extends ApplicationFrame

Fields Summary
private TextLayout
mTextLayout
private int
mX
private int
mY
Constructors Summary
public HitMe()


    
    super("HitMe v1.0");
    addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent me) {
        TextHitInfo hit = mTextLayout.hitTestChar(
            me.getX() - mX, me.getY() - mY);
        System.out.println(hit);
      }
    });
  
Methods Summary
public static voidmain(java.lang.String[] args)

    Frame f = new HitMe();
    f.setTitle("HitMe v1.0");
    f.setVisible(true);
  
public voidpaint(java.awt.Graphics g)

    Graphics2D g2 = (Graphics2D)g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);
    
    String s = "Camelopardalis";
    Font font = new Font("Serif", Font.PLAIN, 32);
    
    if (mTextLayout == null) {
      FontRenderContext frc = g2.getFontRenderContext();
      mTextLayout = new TextLayout(s, font, frc);
    }
    
    mTextLayout.draw(g2, mX, mY);