1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * ident "%Z%%M% %I% %E% SMI" 24 * 25 * Copyright (c) 2000 by Sun Microsystems, Inc. 26 * All rights reserved. 27 */ 28 29/* 30 * Copyright (C) 1996 Active Software, Inc. 31 * All rights reserved. 32 * 33 * @(#) CheckboxShadow.java 1.22 - last change made 08/04/97 34 */ 35 36package sunsoft.jws.visual.rt.shadow.java.awt; 37 38import java.awt.Checkbox; 39import sunsoft.jws.visual.rt.base.Global; 40 41/** 42 * Wraps an AWT widget. The attributes available for this 43 * class are listed below. In the type column, type names beginning 44 * with "sunsoft.jws.visual.rt" have been abbreviated to begin with "rt". 45 * 46 * <pre> 47name type default value 48----------------------------------------------------------------------- 49state java.lang.Boolean false 50text java.lang.String checkbox 51* < /pre> 52* 53* Check the super class for additional attributes. 54* 55* @see Checkbox 56* @version 1.22, 08/04/97 57*/ 58public class CheckboxShadow extends ComponentShadow { 59 public CheckboxShadow() { 60 // A bug in AWT keeps us from changing the label in a checkbox 61 // (the setLabel() method doesn't work.) For now the "text" attribute 62 // is given the CONSTRUCTOR flag to work around this bug. 63 attributes.add(/* NOI18N */"text", /* NOI18N */"java.lang.String", 64 /* JSTYLED */ 65 Global.getMsg("sunsoft.jws.visual.rt.shadow.java.awt.CheckboxShadow.text"), 66 CONSTRUCTOR | NOEDITOR); 67 attributes.add(/* NOI18N */"state", 68 /* NOI18N */"java.lang.Boolean", Boolean.FALSE, 0); 69 } 70 71 protected Object getOnBody(String key) { 72 if (key.equals(/* NOI18N */"text")) 73 return (((Checkbox) body).getLabel()); 74 else if (key.equals(/* NOI18N */"state")) 75 return (new Boolean((((Checkbox) body).getState()))); 76 else 77 return (super.getOnBody(key)); 78 } 79 80 protected void setOnBody(String key, Object value) { 81 if (key.equals(/* NOI18N */"text")) { 82 // WORK-AROUND: this is a constructor attribute because the 83 // call below doesn't actually work (it causes a Motif error) 84 // ((Checkbox) body).setLabel((String) value); 85 } else if (key.equals(/* NOI18N */"state")) { 86 if (((Checkbox) body).getState() 87 != ((Boolean) value).booleanValue()) 88 ((Checkbox) body).setState(((Boolean) value).booleanValue()); 89 } else 90 super.setOnBody(key, value); 91 } 92 93 public void createBody() { 94 String text = (String) get(/* NOI18N */"text"); 95 if (text != null) 96 body = new Checkbox(text); 97 else 98 body = new Checkbox(); 99 } 100} 101