JLabel : Java Glossary


is a component used to display decorative text on the screen to label some other component. The user cannot ever modify the text, unlike JTextfields. In AWT (Advanced Windowing Toolkit) you use Label, in Swing JLabel. JLabel.setHorizonalAlignment ( JLabel. LEFT ) or JLabel.setHorizonalAlignment ( JLabel. RIGHT ) lets you control the justification or the shortcut specification in the constructor. You control positioning of the text within the JLabel with setHorizonalAlignment and setVerticalAlignment and with setBorder.


Multiline Labels

Unfortunately, Oracle does not document just what features of HTML are supported. I discovered by experiment the entity &rArr; is not supported. The renderer does not insist on <body>…</body> tags. I have discovered that JEditorPanes accept <style commands. I have written Oracle asking them to clarify.

Learning More

Oracle’s Javadoc on JLabel class : available:

This page is posted
on the web at:


Optional Replicator mirror
of mindprod.com
on local hard disk J:

Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Your face IP:[]
You are visitor number