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 * @(#) LabelShadow.java 1.26 - last change made 08/04/97 34 */ 35 36package sunsoft.jws.visual.rt.shadow.java.awt; 37 38import sunsoft.jws.visual.rt.type.AlignmentEnum; 39import java.awt.Label; 40import sunsoft.jws.visual.rt.base.Global; 41 42/** 43 * Wraps an AWT widget. The attributes available for this 44 * class are listed below. In the type column, type names beginning 45 * with "sunsoft.jws.visual.rt" have been abbreviated to begin with "rt". 46 * 47 * <pre> 48name type default value 49----------------------------------------------------------------------- 50alignment rt.type.AlignmentEnum center 51text java.lang.String label 52* < /pre> 53* 54* Check the super class for additional attributes. 55* 56* @see Label 57* @version 1.26, 08/04/97 58*/ 59public class LabelShadow extends ComponentShadow { 60 public LabelShadow() { 61 attributes.add(/* NOI18N */"text", /* NOI18N */"java.lang.String", 62 /* JSTYLED */ 63 Global.getMsg("sunsoft.jws.visual.rt.shadow.java.awt.LabelShadow.text"), 64 NOEDITOR); 65 attributes.add(/* NOI18N */"alignment", 66 /* NOI18N */"sunsoft.jws.visual.rt.type.AlignmentEnum", 67 new AlignmentEnum(Label.CENTER), 0); 68 } 69 70 protected Object getOnBody(String key) { 71 if (key.equals(/* NOI18N */"text")) 72 return (((Label) body).getText()); 73 else if (key.equals(/* NOI18N */"alignment")) 74 return (new AlignmentEnum(((Label) body).getAlignment())); 75 else 76 return (super.getOnBody(key)); 77 } 78 79 protected void setOnBody(String key, Object value) { 80 Label label = (Label) body; 81 82 if (key.equals(/* NOI18N */"text")) { 83 String text = label.getText(); 84 if ((value == null && text != null) 85 || (value != null && !value.equals(text))) 86 label.setText((String) value); 87 } else if (key.equals(/* NOI18N */"alignment")) 88 label.setAlignment(((AlignmentEnum) value).intValue()); 89 else 90 super.setOnBody(key, value); 91 } 92 93 public void createBody() { 94 body = new Label(); 95 } 96} 97