Example #1
0
  /**
   * Sets the text in this label to the specified value.
   *
   * @param text The new text for this label.
   */
  public synchronized void setText(String text) {
    this.text = text;

    if (peer != null) {
      LabelPeer lp = (LabelPeer) peer;
      lp.setText(text);
    }
  }
Example #2
0
 /**
  * Sets the text alignment of this label to the specified value.
  *
  * @param alignment The desired alignment for the text in this label, which must be one of <code>
  *     LEFT</code>, <code>CENTER</code>, or <code>RIGHT</code>.
  */
 public synchronized void setAlignment(int alignment) {
   if (alignment != CENTER && alignment != LEFT && alignment != RIGHT)
     throw new IllegalArgumentException("invalid alignment: " + alignment);
   this.alignment = alignment;
   if (peer != null) {
     LabelPeer lp = (LabelPeer) peer;
     lp.setAlignment(alignment);
   }
 }