home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / un2maiq4 / pjjava / src / pj / awt / obsvrlabel.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  2.4 KB  |  89 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.     Written by the Personal Journal developers of Dow Jones & Company, Inc.
  4.  
  5.     Dow Jones makes no representations or warranties about 
  6.     the suitability of this software, either express or 
  7.     implied, including but not limited to the implied warranties 
  8.     of merchantability, fitness for a particular purpose, 
  9.     or non-infringement.  Dow Jones will not be liable for 
  10.     any damages suffered by a user as a result of using, 
  11.     modifying or distributing this software or its derivatives.
  12.  
  13.  
  14.  
  15.     @(#)ObsvrLabel.java   0.00 19-Mar-95
  16.  
  17.         A Label component that has observing capability.
  18.  
  19.     Authors:
  20.  
  21.         jlee        James Lee
  22.  
  23.  
  24.     Version Ident:
  25.  
  26.         $Header$
  27.  
  28.  
  29.     History:
  30.  
  31.         19-Mar-1996    jlee      Initial Creation
  32.         26-Mar-1996    jlee      Changed setText's string parameter which embeds "Persona News".
  33. ---------------------------------------------------------------------------*/
  34.  
  35. package pj.awt;
  36.  
  37. import pj.io.DownloadProgressNotification;
  38. import pj.io.PaperSection;
  39.  
  40. import java.awt.Label;
  41. import java.lang.String;
  42. import java.util.Observer;
  43. import java.util.Observable;
  44.  
  45. /**
  46.  * A Label that can observe.
  47.  * @version 0.00, 19-Mar-96
  48.  * @author      James Lee
  49.  */
  50. public class ObsvrLabel extends Label implements Observer
  51.     {
  52.     // --- Instance variables
  53.     private String  m_strLabel;
  54.     private String  m_strPaperSection;
  55.     private int     m_nStoryCount;
  56.  
  57.     // --- Public constructors
  58.     public ObsvrLabel( String strText, String strPaperSection )
  59.         {
  60.         setText( strText );
  61.         m_strPaperSection = strPaperSection;
  62.         m_nStoryCount = 0;
  63.         }
  64.  
  65.     // --- Public functions
  66.     public void setText( String strText )
  67.         {
  68.         m_strLabel = strText;
  69.         super.setText( strText );
  70.         }
  71.  
  72.     public void update(Observable o, Object arg)
  73.         {
  74.         if ( !(arg instanceof DownloadProgressNotification) )
  75.             return;
  76.  
  77.         DownloadProgressNotification dpnProgress = (DownloadProgressNotification)arg;
  78.  
  79.         if ( !(m_strPaperSection.equals( dpnProgress.strSubsect )) )
  80.             return;
  81.  
  82.         if ( dpnProgress.newState == PaperSection.stateAdding )
  83.             m_nStoryCount++;
  84.  
  85.         super.setText( "Personal News: " + m_nStoryCount + " Stories from the Wall Street Journal" );
  86.         } // update
  87.     } // ObsvrLabel
  88.  
  89.