import browser.Applet;
import awt.Graphics;
import awt.Color;
import awt.Font;

/**
 マウスの操作で表示が反転するアプレット RevName のクラス定義
 */
class RevName extends Applet {

/**
 表示する文字列
 */
       public String message = "Fujio Maruyama";
/**
 マウスがアプレット内にあるかどうかを示すフラグ
 */
       private boolean stateFlag = false;

/**
 初期設定を行う。フォントとアプレットのサイズを調整
 */
       protected void init() {

             this.font = getFont( "TimesRoman", Font.ITALIC, 24 );

             width = this.font.stringWidth( message ) + 10;
             resize( width, 32 );
       }

/**
 アプレットにグラフィックを描く。
 最初の表示の時には自動的に、後は repaint() によって呼び出される。
 */
       public void paint( Graphics g ) {
       /*
         マウスはアプレットの外にある
       */
             if( stateFlag == false ) {
                  g.setForeground( Color.black );
                  g.paint3DRect( 0, 0, width, 32, true, false );
                  g.setForeground( Color.yellow );
                  g.drawString( message, 5, 22 );
             }
       /*
         マウスがアプレットの中にある
       */
             else {
                  g.setForeground( Color.yellow );
                  g.paint3DRect( 0, 0, width, 32, true, true );
                  g.setForeground( Color.black );
                  g.drawString( message, 5, 22 );
             }
       }

/**
 マウスがアプレット内に入った時に自動的に呼び出される。
 */
       public void mouseEnter() {

             stateFlag = true;
             repaint();       // paint() を呼び出す
       }

/**
 マウスがアプレットの外に出た時に自動的に呼び出される。
 */
       public void mouseExit() {

             stateFlag = false;
             repaint();       // paint() を呼び出す
       }
}

