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 |
|
|
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 |
{ |
{ |
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 |
/*************************************************************************/ |
/*************************************************************************/ |
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 |
/*************************************************************************/ |
/*************************************************************************/ |
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 |
/*************************************************************************/ |
/*************************************************************************/ |
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 |
/*************************************************************************/ |
/*************************************************************************/ |