home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / java / awt / CheckboxGroup.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-20  |  1.2 KB  |  29 lines

  1. package java.awt;
  2.  
  3. public class CheckboxGroup {
  4.    Checkbox currentChoice;
  5.  
  6.    public Checkbox getCurrent() {
  7.       return this.currentChoice;
  8.    }
  9.  
  10.    public synchronized void setCurrent(Checkbox box) {
  11.       if (box == null || box.group == this) {
  12.          Checkbox oldChoice = this.currentChoice;
  13.          this.currentChoice = box;
  14.          if (oldChoice != null && oldChoice != box) {
  15.             oldChoice.setState(false);
  16.          }
  17.  
  18.          if (box != null && oldChoice != box && !box.getState()) {
  19.             box.setStateInternal(true);
  20.          }
  21.  
  22.       }
  23.    }
  24.  
  25.    public String toString() {
  26.       return this.getClass().getName() + "[current=" + this.currentChoice + "]";
  27.    }
  28. }
  29.