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.
For example, the code . . .
setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
add(new Label("Hi There!"));
add(new Label("Another Label"));
produces the following labels:
| Modifier and Type | Class and Description |
|---|---|
| protected class | Label.
This class implements accessibility support for the
|
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | alignment
The label's alignment. |
| private static final String | |
| public static final int | CENTER
Indicates that the label should be centered. |
| public static final int | LEFT
Indicates that the label should be left justified. |
| private static int | |
| public static final int | RIGHT
Indicates that the label should be right justified. |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
| pack-priv String | text
The text of this label. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| pack-priv String | constructComponentName()
Overrides java. Construct a name for this component. |
| public AccessibleContext | Returns: an AccessibleAWTLabel that serves as the AccessibleContext of this LabelOverrides java. Implements javax. Gets the AccessibleContext associated with this Label. |
| public int | |
| public String | Returns: the text of this label, ornull if
the text has been set to null.Gets the text of this label. |
| private static native void | |
| protected String | Returns: the parameter string of this labelOverrides java. Returns a string representing the state of this |
| private void | readObject(ObjectInputStream
the s)ObjectInputStream to readHides java. Read a label from an object input stream. |
| public synchronized void | setAlignment(int
the alignment to be set. alignment)Sets the alignment for this label to the specified alignment. |
| public void |
| alignment | back to summary |
|---|---|
| pack-priv int alignment The label's alignment. The default alignment is set to be left justified.
| |
| base | back to summary |
|---|---|
| private static final String base | |
| CENTER | back to summary |
|---|---|
| public static final int CENTER Indicates that the label should be centered. | |
| LEFT | back to summary |
|---|---|
| public static final int LEFT Indicates that the label should be left justified. | |
| nameCounter | back to summary |
|---|---|
| private static int nameCounter | |
| RIGHT | back to summary |
|---|---|
| public static final int RIGHT Indicates that the label should be right justified. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.1 for interoperability. | |
| text | back to summary |
|---|---|
| pack-priv String text The text of this label. This text can be modified by the program but never by the user.
| |
| Label | back to summary |
|---|---|
| public Label() throws HeadlessException Constructs an empty label.
The text of the label is the empty string
| |
| Label | back to summary |
|---|---|
| public Label(String text) throws HeadlessException Constructs a new label with the specified string of text, left justified.
| |
| Label | back to summary |
|---|---|
| public Label(String text, int alignment) throws HeadlessException Constructs a new label that presents the specified string of
text with the specified alignment.
Possible values for
| |
| addNotify | back to summary |
|---|---|
| public void addNotify() Overrides java. Creates the peer for this label. The peer allows us to modify the appearance of the label without changing its functionality. | |
| constructComponentName | back to summary |
|---|---|
| pack-priv String constructComponentName() Overrides java. Construct a name for this component. Called by getName() when the
name is | |
| getAccessibleContext | back to summary |
|---|---|
| public AccessibleContext getAccessibleContext() Overrides java. Implements javax. 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.
| |
| getAlignment | back to summary |
|---|---|
| public int getAlignment() Gets the current alignment of this label. Possible values are
| |
| getText | back to summary |
|---|---|
| public String getText() Gets the text of this label.
| |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() Hides java. Initialize JNI field and method IDs | |
| paramString | back to summary |
|---|---|
| protected String paramString() Overrides java. Returns a string representing the state of this
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException Hides java. Read a label from an object input stream.
| |
| setAlignment | back to summary |
|---|---|
| public synchronized void setAlignment(int alignment) Sets the alignment for this label to the specified alignment.
Possible values are
| |
| setText | back to summary |
|---|---|
| public void setText(String text) Sets the text for this label to the specified text.
| |
Label class. It provides an implementation of the
Java Accessibility API appropriate to label user-interface elements.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides java. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: the localized name of the object -- can be null if this object does not have a nameOverrides java. Get the accessible name of this object. |
| public AccessibleRole | Returns: an instance of AccessibleRole describing the role of the objectOverrides java. Get the role of this object. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.3 for interoperability. | |
| AccessibleAWTLabel | back to summary |
|---|---|
| public AccessibleAWTLabel() Constructor for the accessible label. | |
| getAccessibleName | back to summary |
|---|---|
| public String getAccessibleName() Overrides java. Get the accessible name of this object.
| |
| getAccessibleRole | back to summary |
|---|---|
| public AccessibleRole getAccessibleRole() Overrides java. Get the role of this object.
| |