home *** CD-ROM | disk | FTP | other *** search
/ 100 Great Games for Palm OS 2 / PalmV2012301.ISO / board / Dice / source / Title.java < prev   
Text File  |  2000-05-29  |  744b  |  41 lines

  1. import waba.ui.*;
  2. import waba.fx.*;
  3.  
  4. /**
  5.  * A control that displays an application's title.
  6.  */
  7.  
  8. public class Title extends Control
  9. {
  10. String name;
  11. Font font;
  12.  
  13. public Title(String name)
  14.     {
  15.     this.name = name;
  16.     this.font = new Font("Helvetica", Font.BOLD, 12);
  17.     }
  18.  
  19. public void onPaint(Graphics g)
  20.     {
  21.     // draw line across
  22.     g.setColor(0, 0, 0);
  23.     int y = this.height - 1;
  24.     g.drawLine(0, y, this.width, y);
  25.     y--;
  26.     g.drawLine(0, y, this.width, y);
  27.  
  28.     // draw title
  29.     FontMetrics fm = getFontMetrics(font);
  30.     int boxWidth = fm.getTextWidth(name) + 8;
  31.     g.fillRect(0, 0, boxWidth, y);
  32.     
  33.     g.setColor(255, 255, 255);
  34.     g.fillRect(0,0,1,1);
  35.     g.fillRect(boxWidth-1,0,1,1);
  36.     
  37.     g.setFont(font);
  38.     g.drawText(name, 4, 2);
  39.     }
  40. }
  41.