home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / un2maiq4 / pjjava / src / pj / awt / checkboxtab.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  3.9 KB  |  156 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.     CheckboxTab.java
  15.  
  16.         A tab implemented from a Checkbox.
  17.  
  18.  
  19.     Authors:
  20.  
  21.         rphall          Rick Hall
  22.  
  23.  
  24.     Version Ident:
  25.  
  26.         $Header: /PjJavaClient/src/pj/awt/CheckboxTab.java 2     1/21/96 5:53p Rphall $
  27.  
  28.  
  29.     History:
  30.  
  31.         10-dec-1995 rphalll     Initial Creation
  32.  
  33.  
  34. ---------------------------------------------------------------------------*/
  35.  
  36. package pj.awt;
  37.  
  38. import pj.awt.StringTabSpec;
  39. import pj.awt.Tab;
  40.  
  41. import collections.Assertable;
  42. import collections.ImplementationError;
  43. import java.awt.Checkbox;
  44. import java.awt.CheckboxGroup;
  45. import java.lang.String;
  46.  
  47. /**
  48.  * A tab implemented from a Checkbox.
  49.  *
  50.  * @see pj.awt.Tab
  51.  * @see java.awt.Checkbox
  52.  * @version 0.00 03-Jan-96
  53.  * @author Rick Hall
  54. */
  55. class CheckboxTab extends Checkbox
  56.     implements Assertable, Tab
  57.     {
  58.  
  59.     // --- Public constructors
  60.  
  61.     /**
  62.      * Construct a CheckboxTab.
  63.      * @param tab a string-based specification of this tab.
  64.      * @param group the CheckboxGroup this Checkbox is in
  65.      * @param state the initial state of this Checkbox 
  66.     */
  67.     public CheckboxTab(
  68.             StringTabSpec tab, CheckboxGroup group, boolean selected)
  69.         {
  70.         super((String)tab.objVisSpec, group, selected);
  71.         strTabName = tab.strTabName;
  72.         strPageName = tab.strPageName;
  73.         }
  74.  
  75.     // --- Public operations
  76.  
  77.     /**
  78.      * Raise an exception if predicate is false.
  79.      * @see collections.Assertable
  80.     */
  81.     public void assert(boolean predicate) throws ImplementationError
  82.         { ImplementationError.assert(this, predicate); }
  83.  
  84.     /**
  85.      * @param tabname The name for this tab.
  86.     */
  87.     public void setName(String tabname)
  88.         { strTabName = tabname; }
  89.  
  90.     /**
  91.      * @return The name for this tab.
  92.     */
  93.     public String getName()
  94.         { return strTabName; }
  95.  
  96.     /**
  97.      * Get a tab's name.
  98.      * Equivalent to getName().
  99.      *
  100.      * @return The internal id of a tab within a TabBar.
  101.      * @see getName
  102.     */
  103.     public String getTabName()
  104.         { return getName(); }
  105.  
  106.     /**
  107.      * @param object The page name mapped to this tab.
  108.      * @exception ImplementationError thrown if object is not an instance
  109.      * of String
  110.     */
  111.     public void setMappedObject(Object object)
  112.         throws ImplementationError
  113.         {
  114.         assert(object instanceof String);
  115.         strPageName = (String)object;
  116.         }
  117.  
  118.     /**
  119.      * @return The page name mapped to this tab.
  120.     */
  121.     public Object getMappedObject()
  122.         { return strPageName; }
  123.  
  124.     /**
  125.      * Get the mapped name of a tab.
  126.      * Equivalent to ((String)getMappedObject()).
  127.      *
  128.      * @return The name of the page which this tab references.
  129.      * @see pj.util.Mappable#getMappedName
  130.     */
  131.     public String getPageName()
  132.         { return (String)getMappedObject(); }
  133.  
  134.     /**
  135.      * @param visual The string presentation of this tab.
  136.      * @exception ImplementationError if visual is not an instance of String
  137.     */
  138.     public void setTabVisual(Object visual)
  139.         {
  140.         assert(visual instanceof String);
  141.         setLabel((String)visual);
  142.         }
  143.  
  144.     /**
  145.      * @return The String presentation of this tab.
  146.     */
  147.     public Object getTabVisual()
  148.         { return getLabel(); }
  149.  
  150.     // --- Private attributes
  151.  
  152.     String strTabName;
  153.     String strPageName;
  154.  
  155.     } // Tab
  156.