home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / init / messages.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.4 KB  |  60 lines

  1. // Messages.java
  2. // 25.03.96
  3. //
  4. // Initialization messages
  5.  
  6. package cybcerone.init;
  7.  
  8. import java.awt.Rectangle;
  9. import java.awt.Color;
  10. import java.awt.Graphics;
  11. import java.util.Vector;
  12. import java.util.Enumeration;
  13.  
  14. import cybcerone.utils.Appletlike;
  15. import cybcerone.utils.IdPanel;
  16. import cybcerone.utils.Fonts;
  17.  
  18. class Messages extends IdPanel {
  19.   private static final Rectangle placement = new Rectangle(467, 458, 419, 165);
  20.   
  21.   private static final String id = "Messages";
  22.   private static final String statusText = "Initialization log";
  23.  
  24.   private static final Color gray = new Color (127, 127, 127);
  25.   private static final int maxSize = 8;
  26.   private static final int startY = scale (20);
  27.   private static final int yIncr = scale (20);
  28.  
  29.   private Vector messages;
  30.   private int y;
  31.  
  32.   public Messages (Appletlike app) {
  33.     super (id, statusText, app);
  34.     reshape (placement);
  35.     messages = new Vector ();
  36.   }
  37.  
  38.   public void update (String newMessage) {
  39.     messages.addElement (newMessage);
  40.     if (messages.size() > maxSize)
  41.       messages.removeElementAt (0);
  42.     repaint ();
  43.   }
  44.  
  45.   public void paint (Graphics g) {
  46.     g.setColor (getBackground ());
  47.     g.fillRect (0, 0, size().width, size().height);
  48.  
  49.     g.setColor (Color.white);
  50.     g.setFont (Fonts.tinyFont);
  51.     y = startY;
  52.     for (Enumeration e = messages.elements ();
  53.      e.hasMoreElements ();) {
  54.       g.drawString ((String)e.nextElement(), 10, y);
  55.       y += yIncr;
  56.     }
  57.   }
  58.  
  59. }
  60.