| public class java.awt Label
|
Java SE 6 |
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:
| version | 1.59, 04/07/06 |
| since | JDK1.0 |
| Fields | |||
|---|---|---|---|
| final public static int | LEFT Indicates that the label should be left justified. | ||
| final public static int | CENTER Indicates that the label should be centered. | ||
| final public static int | RIGHT Details
Indicates that the label should be right justified.
| ||
| Constructors | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| public | Label() throws HeadlessException Details
Constructs an empty label.
The text of the label is the empty string "".
| ||||||||
| public | Label(String text) throws HeadlessException Details
Constructs a new label with the specified string of text,
left justified.
| ||||||||
| public | Label(String text, int alignment) throws HeadlessException Details
Constructs a new label that presents the specified string of
text with the specified alignment.
Possible values for alignment are Label.LEFT,
Label.RIGHT, and Label.CENTER.
| ||||||||
| Methods | |||
|---|---|---|---|
| public void | addNotify() Creates the peer for this label. The peer allows us to modify the appearance of the label without changing its functionality. | ||
| protected String | paramString() Details
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.
| ||
| Properties | |||||||
|---|---|---|---|---|---|---|---|
| public AccessibleContext | getAccessibleContext() Details
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.
| ||||||
| public void | setAlignment(int alignment) Details
Sets the alignment for this label to the specified alignment.
Possible values are Label.LEFT,
Label.RIGHT, and Label.CENTER.
| ||||||
| public int | getAlignment() Details
Gets the current alignment of this label. Possible values are
Label.LEFT, Label.RIGHT, and
Label.CENTER.
| ||||||
| public void | setText(String text) Details
Sets the text for this label to the specified text.
| ||||||
| public String | getText() Details
Gets the text of this label.
| ||||||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2013 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|