Sample Code: LabelShadow.java

# Sample Code: `LabelShadow.java`

    /*
     *              Copyright (C) 1997  SunSoft
     *                  All rights reserved.
     *
     * @(#) LabelShadow.java 1.18 - last change made 25 Apr 1996
     */

    package sunsoft.jws.visual.rt.shadow.java.awt;

    import sunsoft.jws.visual.rt.type.AlignmentEnum;
    import java.awt.Label;

    public class LabelShadow extends ComponentShadow {
      public LabelShadow() {
        attributes.add("text", "java.lang.String", "label", 0);
        attributes.add("alignment", "sunsoft.jws.visual.rt.type.AlignmentEnum",
    		   new AlignmentEnum(Label.CENTER));
      }

      protected Object getOnBody(String key) {
        if (key.equals("text"))
          return(((Label) body).getText());
        else if (key.equals("alignment"))
          return(new AlignmentEnum(((Label) body).getAlignment()));
        else
          return(super.getOnBody(key));
      }

      protected void setOnBody(String key, Object value) {
        if (key.equals("text"))
          ((Label) body).setText((String) value);
        else if (key.equals("alignment"))
          ((Label) body).setAlignment(((AlignmentEnum) value).intValue());
        else
          super.setOnBody(key, value);
      }

      public void createBody() {
        body = new Label();
      }
    }