CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Drawing String

  1. #1
    Join Date
    May 1999
    Location
    Maharastra, India
    Posts
    32

    Drawing String

    Hi,

    Now i am with a new problem. I am drawing a string in a container using g.drawString(String,0,0);
    Now i want to add a underline to the string in the container. How is it possible
    Thanks in advance




  2. #2
    Join Date
    Jul 1999
    Posts
    4

    Re: Drawing String

    Try something like

    import java.applet.*;
    import java.awt.*;

    public class underlineText extends Applet{
    String s = "Underlined text";
    int x=0;
    int y=0;

    public void init() {}

    public void paint(Graphics g) {
    g.drawString(s, x,y);
    g.drawLine(x , y+2 , x+getFontMetrics(getFont()).stringWidth(s) , y+2 );
    }
    }




    ---
    Real Gagnon
    Java Javascript and PowerBuilder How-to
    http://www.tactika.com/realhome

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured