- Label example in java
- Nested Class Summary
- Nested classes/interfaces declared in class java.awt.Component
- Field Summary
- Fields declared in class java.awt.Component
- Fields declared in interface java.awt.image.ImageObserver
- Constructor Summary
- Method Summary
- Methods declared in class java.awt.Component
- Methods declared in class java.lang.Object
- Field Detail
- LEFT
- CENTER
- RIGHT
- Constructor Detail
- Label
- Label
- Label
- Method Detail
- addNotify
- getAlignment
- setAlignment
- getText
- setText
- paramString
- getAccessibleContext
- Class Label
- Nested Class Summary
- Nested classes/interfaces declared in class java.awt.Component
- Field Summary
- Fields declared in class java.awt.Component
- Fields declared in interface java.awt.image.ImageObserver
- Constructor Summary
- Method Summary
- Methods declared in class java.awt.Component
- Methods declared in class java.lang.Object
- Field Details
- LEFT
- CENTER
- RIGHT
- Constructor Details
- Label
- Label
- Label
- Method Details
- addNotify
- getAlignment
- setAlignment
- getText
- setText
- paramString
- getAccessibleContext
- Class Label
- Nested Class Summary
- Nested classes/interfaces declared in class java.awt.Component
- Field Summary
- Fields declared in class java.awt.Component
- Fields declared in interface java.awt.image.ImageObserver
- Constructor Summary
- Method Summary
- Methods declared in class java.awt.Component
- Methods declared in class java.lang.Object
- Field Details
- LEFT
- CENTER
- RIGHT
- Constructor Details
- Label
- Label
- Label
- Method Details
- addNotify
- getAlignment
- setAlignment
- getText
- setText
- paramString
- getAccessibleContext
- Label example in java
- Learn Latest Tutorials
- Preparation
- Trending Technologies
- B.Tech / MCA
- Javatpoint Services
- Training For College Campus
Label example in java
A 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"));
Nested Class Summary
Nested classes/interfaces declared in class java.awt.Component
Field Summary
Fields declared in class java.awt.Component
Fields declared in interface java.awt.image.ImageObserver
Constructor Summary
Method Summary
Methods declared in class java.awt.Component
Methods declared in class java.lang.Object
Field Detail
LEFT
public static final int LEFT
CENTER
public static final int CENTER
RIGHT
public static final int RIGHT
Constructor Detail
Label
Label
public Label(String text) throws HeadlessException
Label
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 alignment are Label.LEFT , Label.RIGHT , and Label.CENTER .
Method Detail
addNotify
Creates the peer for this label. The peer allows us to modify the appearance of the label without changing its functionality.
getAlignment
Gets the current alignment of this label. Possible values are Label.LEFT , Label.RIGHT , and Label.CENTER .
setAlignment
public void setAlignment(int alignment)
Sets the alignment for this label to the specified alignment. Possible values are Label.LEFT , Label.RIGHT , and Label.CENTER .
getText
setText
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 .
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.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
Class Label
A 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.
setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10)); add(new Label("Hi There!")); add(new Label("Another Label"));
produces the following labels:
Nested Class Summary
Nested classes/interfaces declared in class java.awt.Component
Field Summary
Fields declared in class java.awt.Component
Fields declared in interface java.awt.image.ImageObserver
Constructor Summary
Method Summary
Methods declared in class java.awt.Component
Methods declared in class java.lang.Object
Field Details
LEFT
CENTER
RIGHT
Constructor Details
Label
Label
Label
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 .
Method Details
addNotify
Creates the peer for this label. The peer allows us to modify the appearance of the label without changing its functionality.
getAlignment
Gets the current alignment of this label. Possible values are Label.LEFT , Label.RIGHT , and Label.CENTER .
setAlignment
Sets the alignment for this label to the specified alignment. Possible values are Label.LEFT , Label.RIGHT , and Label.CENTER .
getText
setText
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 .
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.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
Class Label
A 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.
setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10)); add(new Label("Hi There!")); add(new Label("Another Label"));
produces the following labels:
Nested Class Summary
Nested classes/interfaces declared in class java.awt.Component
Field Summary
Fields declared in class java.awt.Component
Fields declared in interface java.awt.image.ImageObserver
Constructor Summary
Method Summary
Methods declared in class java.awt.Component
Methods declared in class java.lang.Object
Field Details
LEFT
CENTER
RIGHT
Constructor Details
Label
Label
Label
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 .
Method Details
addNotify
Creates the peer for this label. The peer allows us to modify the appearance of the label without changing its functionality.
getAlignment
Gets the current alignment of this label. Possible values are Label.LEFT , Label.RIGHT , and Label.CENTER .
setAlignment
Sets the alignment for this label to the specified alignment. Possible values are Label.LEFT , Label.RIGHT , and Label.CENTER .
getText
setText
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 .
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.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
Label example in java
Learn Latest Tutorials
Preparation
Trending Technologies
B.Tech / MCA
Javatpoint Services
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
- Website Designing
- Website Development
- Java Development
- PHP Development
- WordPress
- Graphic Designing
- Logo
- Digital Marketing
- On Page and Off Page SEO
- PPC
- Content Development
- Corporate Training
- Classroom and Online Training
- Data Entry
Training For College Campus
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week
Like/Subscribe us for latest updates or newsletter