A tour of swing

JLabel:

 

JLabel, descended from JComponent, is used to create text labels. A JLabel object provides text instructions or information on a GUI — display a single line of read-only text, an image or both text and image. We use a Swing JLabel when we need a user interface component that displays a message or an image.


  • Features:
  • => Provide text instructions on a GUI
  • => label is a Read-only text
  • => label Programs rarely change a label’s contents
  • => labelClass JLabel (subclass of JComponent)

 

Constructors:

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


JLabel(Icon image) - Creates a JLabel instance with the specified image.


JLabel(Icon image, int horizontalAlignment) - Creates a JLabel instance with the specified image and horizontal alignment.


JLabel(String text) - Creates a JLabel instance with the specified text.


JLabel(String text, Icon icon, int horizontalAlignment) - Creates a JLabel instance with the specified text, image, and horizontal alignment.


JLabel(String text, int horizontalAlignment) - Creates a JLabel instance with the specified text and horizontal alignment.

 

Next

JComponents

a tour of SWING by Mrs.s.sharmila banu & MRs.R.jayabharahti