Java Swing: JLabel

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:04 AM on 4/19/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

14 Terms

1
New cards

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.

2
New cards

JComponent

JLabel inherits ______ class.

3
New cards
public class JLabel extends JComponent implements SwingConstants, Accessible

JLabel class declaration

4
New cards

JLabel()
JLabel(String s)
JLabel(Icon i)
JLabel(String s, Icon i, int horizontalAlignment)

Commonly used Constructors in JLabel:

5
New cards

JLabel()

Creates a JLabel instance with no image and with an empty string for the title.

6
New cards

JLabel(String s)

Creates a JLabel instance with the specified text.

7
New cards

JLabel(Icon i)

Creates a JLabel instance with the specified image/icon.

8
New cards

JLabel(String s, Icon i, int horizontalAlignment)

Creates a JLabel instance with the specified text, image, and horizontal alignment.

9
New cards

String getText()
void setText(String text)
void setHorizontalAlignment(int alignment)
Icon getIcon()
int getHorizontalAlignment()

Commonly used Methods in JLabel:

10
New cards

String getText()

It returns the text string that a label displays.

11
New cards

void setText(String text)

It defines the single line of text this component will display.

12
New cards

void setHorizontalAlignment(int alignment)

It sets the alignment of the label's contents along the X axis.

13
New cards

Icon getIcon()

It returns the graphic image that the label displays.

14
New cards

int getHorizontalAlignment()

It returns the alignment of the label's contents along the X axis.