Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
May 21, 2001

How to Write Underlined Text


Interestingly, underline is not a supported font style, i.e., you cannot say Font.UNDERLINE to draw an underlined text.

The trick is to use Graphics.drawLine() method to draw a line just below the text. Take a look at the following program:
 
// UnderlineTextDemo.java

import java.awt.*;

/** Demonstrates how to draw underlined text. */
public class UnderlineTextDemo extends Frame {

  /** The demo text. */
  public static String DEMO_TEXT = 
Shantanu Garg
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap