Methods Summary |
---|
public void | addNotify()Creates the peer for this label. The peer allows us to
modify the appearance of the label without changing its
functionality.
synchronized (getTreeLock()) {
if (peer == null)
peer = getToolkit().createLabel(this);
super.addNotify();
}
|
java.lang.String | constructComponentName()Construct a name for this component. Called by getName() when the
name is null .
synchronized (getClass()) {
return base + nameCounter++;
}
|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this Label.
For labels, the AccessibleContext takes the form of an
AccessibleAWTLabel.
A new AccessibleAWTLabel instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleAWTLabel();
}
return accessibleContext;
|
public int | getAlignment()Gets the current alignment of this label. Possible values are
Label.LEFT , Label.RIGHT , and
Label.CENTER .
return alignment;
|
public java.lang.String | getText()Gets the text of this label.
return text;
|
private static native void | initIDs()Initialize JNI field and method IDs
|
protected java.lang.String | paramString()Returns a string representing the state of this Label .
This method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null .
String str = ",align=";
switch (alignment) {
case LEFT: str += "left"; break;
case CENTER: str += "center"; break;
case RIGHT: str += "right"; break;
}
return super.paramString() + str + ",text=" + text;
|
private void | readObject(java.io.ObjectInputStream s)Read a label from an object input stream.
GraphicsEnvironment.checkHeadless();
s.defaultReadObject();
|
public synchronized void | setAlignment(int alignment)Sets the alignment for this label to the specified alignment.
Possible values are Label.LEFT ,
Label.RIGHT , and Label.CENTER .
switch (alignment) {
case LEFT:
case CENTER:
case RIGHT:
this.alignment = alignment;
LabelPeer peer = (LabelPeer)this.peer;
if (peer != null) {
peer.setAlignment(alignment);
}
return;
}
throw new IllegalArgumentException("improper alignment: " + alignment);
|
public void | setText(java.lang.String text)Sets the text for this label to the specified text.
boolean testvalid = false;
synchronized (this) {
if (text != this.text && (this.text == null ||
!this.text.equals(text))) {
this.text = text;
LabelPeer peer = (LabelPeer)this.peer;
if (peer != null) {
peer.setText(text);
}
testvalid = true;
}
}
// This could change the preferred size of the Component.
if (testvalid && valid) {
invalidate();
}
|