FileDocCategorySizeDatePackage
HelloJava2.javaAPI DocExample1069Mon May 01 14:41:38 BST 2000None

HelloJava2

public class HelloJava2 extends JComponent implements MouseMotionListener

Fields Summary
int
messageX
int
messageY
String
theMessage
Constructors Summary
public HelloJava2(String message)


     
    theMessage = message;
    addMouseMotionListener(this);
  
Methods Summary
public static voidmain(java.lang.String[] args)

    JFrame f = new JFrame("HelloJava2");
    // Make the application exit when the window is closed.
    f.addWindowListener(new WindowAdapter(  ) {
      public void windowClosing(WindowEvent we) { System.exit(0); }
    });
    f.setSize(300, 300);
    f.getContentPane(  ).add(new HelloJava2("Hello, Java!"));
    f.setVisible(true);
  
public voidmouseDragged(java.awt.event.MouseEvent e)

    // Save the mouse coordinates and paint the message.
    messageX = e.getX(  );
    messageY = e.getY(  );
    repaint(  );
  
public voidmouseMoved(java.awt.event.MouseEvent e)

public voidpaintComponent(java.awt.Graphics g)

    g.drawString(theMessage, messageX, messageY);