/[classpath]/classpath/java/awt/Label.java
ViewVC logotype

Diff of /classpath/java/awt/Label.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mark, Sun Jan 13 15:45:15 2002 UTC revision 1.6 by tromey, Wed Jan 16 16:46:46 2002 UTC
# Line 1  Line 1 
1  /* Label.java -- Java label widget  /* Label.java -- Java label widget
2     Copyright (C) 1999 Free Software Foundation, Inc.     Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 35  import java.awt.peer.ComponentPeer; Line 35  import java.awt.peer.ComponentPeer;
35    * be edited.    * be edited.
36    *    *
37    * @author Aaron M. Renn (arenn@urbanophile.com)    * @author Aaron M. Renn (arenn@urbanophile.com)
38      * @author Tom Tromey <tromey@cygnus.com>
39    */    */
40  public class Label extends Component implements java.io.Serializable  public class Label extends Component implements java.io.Serializable
41  {  {
# Line 122  Label(String text) Line 123  Label(String text)
123  public  public
124  Label(String text, int alignment)  Label(String text, int alignment)
125  {  {
126    this.text = text;    setAlignment (alignment);
127    this.alignment = alignment;    setText (text);
128  }  }
129    
130  /*************************************************************************/  /*************************************************************************/
# Line 157  getAlignment() Line 158  getAlignment()
158  public synchronized void  public synchronized void
159  setAlignment(int alignment)  setAlignment(int alignment)
160  {  {
161      if (alignment != CENTER && alignment != LEFT && alignment != RIGHT)
162        throw new IllegalArgumentException ("invalid alignment: " + alignment);
163    this.alignment = alignment;    this.alignment = alignment;
164      if (peer != null)
165    LabelPeer lp = (LabelPeer)getPeer();      {
166    if (lp != null)        LabelPeer lp = (LabelPeer) peer;
167      lp.setAlignment(alignment);        lp.setAlignment (alignment);
168        }
169  }  }
170    
171  /*************************************************************************/  /*************************************************************************/
# Line 189  setText(String text) Line 193  setText(String text)
193  {  {
194    this.text = text;    this.text = text;
195    
196    LabelPeer lp = (LabelPeer)getPeer();    if (peer != null)
197    if (lp != null)      {
198      lp.setText(text);        LabelPeer lp = (LabelPeer) peer;
199          lp.setText (text);
200        }
201  }  }
202    
203  /*************************************************************************/  /*************************************************************************/
# Line 204  setText(String text) Line 210  setText(String text)
210  public void  public void
211  addNotify()  addNotify()
212  {  {
213    setPeer((ComponentPeer)getToolkit().createLabel(this));    if (peer == null)
214        peer = getToolkit ().createLabel (this);
215      super.addNotify ();
216  }  }
217    
218  /*************************************************************************/  /*************************************************************************/

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26