This Java tip demostrates how to draw a text on a component face. The text can be drawn by overwriting the paint() function of the component.

 public void paint(Graphics g) {

        // Set the font for example Lucida Sans Typewriter if it is
        // different from the default font
        String family = "Lucida Sans Typewriter";
        int style = Font.PLAIN;
        int size = 18;
        Font font = new Font(family, style, size);

        // Draw a text such that its base line is at x, y
        int x = 10;
        int y = 10;

        g.drawString("Text", x, y);
        // Draw a text such that the top-left corner is at x, y
        x = 10;
        y = 30;
        FontMetrics fontMetrics = g.getFontMetrics();
        g.drawString("text", x, y+fontMetrics.getAscent());