import java.awt.event.*;
import javax.swing.*;
public class TextDrawingExample extends JFrame {

    public TextDrawingExample (String title) {
        super(title);
        addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                getGraphics().drawString("Hello", e.getX(), e.getY());
            }});
            
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(300, 300);
    }

    public static void main(String args[]) {
        new TextDrawingExample("Text Drawing Example").setVisible(true);
    }
}