< prev index next >
src/java.desktop/share/classes/java/awt/Label.java
Print this page
*** 28,38 ****
import java.io.IOException;
import java.io.ObjectInputStream;
import javax.accessibility.*;
/**
! * A <code>Label</code> object is a component for placing text in a
* container. A label displays a single line of read-only text.
* The text can be changed by the application, but a user cannot edit it
* directly.
* <p>
* For example, the code . . .
--- 28,38 ----
import java.io.IOException;
import java.io.ObjectInputStream;
import javax.accessibility.*;
/**
! * A {@code Label} object is a component for placing text in a
* container. A label displays a single line of read-only text.
* The text can be changed by the application, but a user cannot edit it
* directly.
* <p>
* For example, the code . . .
*** 105,115 ****
*/
private static final long serialVersionUID = 3094126758329070636L;
/**
* Constructs an empty label.
! * The text of the label is the empty string <code>""</code>.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public Label() throws HeadlessException {
--- 105,115 ----
*/
private static final long serialVersionUID = 3094126758329070636L;
/**
* Constructs an empty label.
! * The text of the label is the empty string {@code ""}.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public Label() throws HeadlessException {
*** 118,128 ****
/**
* Constructs a new label with the specified string of text,
* left justified.
* @param text the string that the label presents.
! * A <code>null</code> value
* will be accepted without causing a NullPointerException
* to be thrown.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
--- 118,128 ----
/**
* Constructs a new label with the specified string of text,
* left justified.
* @param text the string that the label presents.
! * A {@code null} value
* will be accepted without causing a NullPointerException
* to be thrown.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*** 132,145 ****
}
/**
* Constructs a new label that presents the specified string of
* text with the specified alignment.
! * Possible values for <code>alignment</code> are <code>Label.LEFT</code>,
! * <code>Label.RIGHT</code>, and <code>Label.CENTER</code>.
* @param text the string that the label presents.
! * A <code>null</code> value
* will be accepted without causing a NullPointerException
* to be thrown.
* @param alignment the alignment value.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
--- 132,145 ----
}
/**
* Constructs a new label that presents the specified string of
* text with the specified alignment.
! * Possible values for {@code alignment} are {@code Label.LEFT},
! * {@code Label.RIGHT}, and {@code Label.CENTER}.
* @param text the string that the label presents.
! * A {@code null} value
* will be accepted without causing a NullPointerException
* to be thrown.
* @param alignment the alignment value.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
*** 152,163 ****
}
/**
* Read a label from an object input stream.
* @exception HeadlessException if
! * <code>GraphicsEnvironment.isHeadless()</code> returns
! * <code>true</code>
* @serial
* @since 1.4
* @see java.awt.GraphicsEnvironment#isHeadless
*/
private void readObject(ObjectInputStream s)
--- 152,163 ----
}
/**
* Read a label from an object input stream.
* @exception HeadlessException if
! * {@code GraphicsEnvironment.isHeadless()} returns
! * {@code true}
* @serial
* @since 1.4
* @see java.awt.GraphicsEnvironment#isHeadless
*/
private void readObject(ObjectInputStream s)
*** 166,176 ****
s.defaultReadObject();
}
/**
* Construct a name for this component. Called by getName() when the
! * name is <code>null</code>.
*/
String constructComponentName() {
synchronized (Label.class) {
return base + nameCounter++;
}
--- 166,176 ----
s.defaultReadObject();
}
/**
* Construct a name for this component. Called by getName() when the
! * name is {@code null}.
*/
String constructComponentName() {
synchronized (Label.class) {
return base + nameCounter++;
}
*** 189,214 ****
}
}
/**
* Gets the current alignment of this label. Possible values are
! * <code>Label.LEFT</code>, <code>Label.RIGHT</code>, and
! * <code>Label.CENTER</code>.
* @return the alignment of this label
* @see java.awt.Label#setAlignment
*/
public int getAlignment() {
return alignment;
}
/**
* Sets the alignment for this label to the specified alignment.
! * Possible values are <code>Label.LEFT</code>,
! * <code>Label.RIGHT</code>, and <code>Label.CENTER</code>.
* @param alignment the alignment to be set.
* @exception IllegalArgumentException if an improper value for
! * <code>alignment</code> is given.
* @see java.awt.Label#getAlignment
*/
public synchronized void setAlignment(int alignment) {
switch (alignment) {
case LEFT:
--- 189,214 ----
}
}
/**
* Gets the current alignment of this label. Possible values are
! * {@code Label.LEFT}, {@code Label.RIGHT}, and
! * {@code Label.CENTER}.
* @return the alignment of this label
* @see java.awt.Label#setAlignment
*/
public int getAlignment() {
return alignment;
}
/**
* Sets the alignment for this label to the specified alignment.
! * Possible values are {@code Label.LEFT},
! * {@code Label.RIGHT}, and {@code Label.CENTER}.
* @param alignment the alignment to be set.
* @exception IllegalArgumentException if an improper value for
! * {@code alignment} is given.
* @see java.awt.Label#getAlignment
*/
public synchronized void setAlignment(int alignment) {
switch (alignment) {
case LEFT:
*** 224,247 ****
throw new IllegalArgumentException("improper alignment: " + alignment);
}
/**
* Gets the text of this label.
! * @return the text of this label, or <code>null</code> if
! * the text has been set to <code>null</code>.
* @see java.awt.Label#setText
*/
public String getText() {
return text;
}
/**
* Sets the text for this label to the specified text.
* @param text the text that this label displays. If
! * <code>text</code> is <code>null</code>, it is
* treated for display purposes like an empty
! * string <code>""</code>.
* @see java.awt.Label#getText
*/
public void setText(String text) {
boolean testvalid = false;
synchronized (this) {
--- 224,247 ----
throw new IllegalArgumentException("improper alignment: " + alignment);
}
/**
* Gets the text of this label.
! * @return the text of this label, or {@code null} if
! * the text has been set to {@code null}.
* @see java.awt.Label#setText
*/
public String getText() {
return text;
}
/**
* Sets the text for this label to the specified text.
* @param text the text that this label displays. If
! * {@code text} is {@code null}, it is
* treated for display purposes like an empty
! * string {@code ""}.
* @see java.awt.Label#getText
*/
public void setText(String text) {
boolean testvalid = false;
synchronized (this) {
*** 261,275 ****
invalidateIfValid();
}
}
/**
! * Returns a string representing the state of this <code>Label</code>.
* 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
! * <code>null</code>.
*
* @return the parameter string of this label
*/
protected String paramString() {
String align = "";
--- 261,275 ----
invalidateIfValid();
}
}
/**
! * Returns a string representing the state of this {@code 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
! * {@code null}.
*
* @return the parameter string of this label
*/
protected String paramString() {
String align = "";
*** 309,319 ****
return accessibleContext;
}
/**
* This class implements accessibility support for the
! * <code>Label</code> class. It provides an implementation of the
* Java Accessibility API appropriate to label user-interface elements.
* @since 1.3
*/
protected class AccessibleAWTLabel extends AccessibleAWTComponent
{
--- 309,319 ----
return accessibleContext;
}
/**
* This class implements accessibility support for the
! * {@code Label} class. It provides an implementation of the
* Java Accessibility API appropriate to label user-interface elements.
* @since 1.3
*/
protected class AccessibleAWTLabel extends AccessibleAWTComponent
{
< prev index next >