home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 2.6 KB | 97 lines |
- /*---------------------------------------------------------------------------
-
- Written by the Personal Journal developers of Dow Jones & Company, Inc.
-
- Dow Jones makes no representations or warranties about
- the suitability of this software, either express or
- implied, including but not limited to the implied warranties
- of merchantability, fitness for a particular purpose,
- or non-infringement. Dow Jones will not be liable for
- any damages suffered by a user as a result of using,
- modifying or distributing this software or its derivatives.
-
-
- @(#)TextCanvas.java 0.00 17-Jan-96
-
- A canvas that displays text.
-
- Authors:
-
- jlee James Lee
-
- Version Ident:
-
- $Header$
-
- History:
-
- 28-Mar-96 jlee Initial creation
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
- import pj.awt.PjFinals;
-
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.lang.Integer;
- import java.util.Vector;
-
- /**
- * A canvas that displays text.
- *
- * @version 0.00 28-Mar-96
- * @author jlee
- */
- public class TextCanvas extends Canvas
- {
- // --- Instance variables
- private Vector vText = new Vector();
- private Vector vFontStyle = new Vector();
-
-
- // --- Public constructor
-
- public void paint(Graphics g)
- {
- g.setColor( Color.black );
- g.setFont( PjFinals.fntAboutBoxTextBold );
-
- FontMetrics fmBoxText = g.getFontMetrics();
-
- int nFontHeight = fmBoxText.getHeight();
-
- for ( int i = 0; i < vText.size(); i++ )
- {
- switch ( ((Integer)vFontStyle.elementAt(i)).intValue() )
- {
- case 0: //PLAIN
- g.setFont( PjFinals.fntAboutBoxTextPlain );
- break;
- case 1: //BOLD
- g.setFont( PjFinals.fntAboutBoxTextBold );
- break;
- case 2: //ITALIC
- g.setFont( PjFinals.fntAboutBoxTextItalic );
- break;
- default:
- g.setFont( PjFinals.fntAboutBoxTextPlain );
- break;
- }
- g.drawString( (String)vText.elementAt(i), 4, (i + 1) * nFontHeight );
- }
- }
-
- public void addText( String str, int nFontStyle )
- {
- vText.addElement( str );
- vFontStyle.addElement( new Integer( nFontStyle ) );
- }
-
- // --- Private operations
-
- }//TextCanvas
-
-