home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / solaris2 / jdk / src / java / awt / checkbo1.jav < prev    next >
Encoding:
Text File  |  1995-10-30  |  2.0 KB  |  69 lines

  1. /*
  2.  * @(#)CheckboxGroup.java    1.6 95/08/17 Sami Shaio
  3.  *
  4.  * Copyright (c) 1994-1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19. package java.awt;
  20.  
  21. /**
  22.  * This class is used to create a multiple-exclusion scope for a set
  23.  * of Checkbox buttons. For example, creating a set of Checkbox buttons
  24.  * with the same RadioGroup object means that only one of those Checkbox
  25.  * buttons will be allowed to be "on" at a time.
  26.  *
  27.  * @version     1.6 08/17/95
  28.  * @author     Sami Shaio
  29.  */
  30. public class CheckboxGroup {
  31.     /**
  32.      * The current choice.
  33.      */
  34.     Checkbox currentChoice = null;
  35.  
  36.     /**
  37.      * Creates a new CheckboxGroup.
  38.      */
  39.     public CheckboxGroup() {
  40.     }
  41.  
  42.     /**
  43.      * Gets the current choice.
  44.      */
  45.     public Checkbox getCurrent() {
  46.     return currentChoice;
  47.     }
  48.  
  49.     /**
  50.      * Sets the current choice to the specified Checkbox.
  51.      * @param t the Checkbox to be set to
  52.      */
  53.     public synchronized void setCurrent(Checkbox t) {
  54.     Checkbox oldChoice = this.currentChoice;
  55.     this.currentChoice = t;
  56.     if ((oldChoice != null) && (oldChoice != t)) {
  57.         oldChoice.setState(false);
  58.     }
  59.     }
  60.  
  61.     /**
  62.      * Returns the String representation of this CheckboxGroup's values.
  63.      * Convert to String.
  64.      */
  65.     public String toString() {
  66.     return getClass().getName() + "[current=" + currentChoice + "]";
  67.     }
  68. }
  69.