1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
JLabel
The object of ______ class is a component for placing text in a container. It is used to display a single line of read only text. The text can be changed by an application but a user cannot edit it directly.
JComponent
JLabel inherits ______ class.
public class JLabel extends JComponent implements SwingConstants, AccessibleJLabel class declaration
JLabel()
JLabel(String s)
JLabel(Icon i)
JLabel(String s, Icon i, int horizontalAlignment)
Commonly used Constructors in JLabel:
JLabel()
Creates a JLabel instance with no image and with an empty string for the title.
JLabel(String s)
Creates a JLabel instance with the specified text.
JLabel(Icon i)
Creates a JLabel instance with the specified image/icon.
JLabel(String s, Icon i, int horizontalAlignment)
Creates a JLabel instance with the specified text, image, and horizontal alignment.
String getText()
void setText(String text)
void setHorizontalAlignment(int alignment)
Icon getIcon()
int getHorizontalAlignment()
Commonly used Methods in JLabel:
String getText()
It returns the text string that a label displays.
void setText(String text)
It defines the single line of text this component will display.
void setHorizontalAlignment(int alignment)
It sets the alignment of the label's contents along the X axis.
Icon getIcon()
It returns the graphic image that the label displays.
int getHorizontalAlignment()
It returns the alignment of the label's contents along the X axis.