16.5. Enabling Applets to Run as Applications

 
[Page 503 ( continued )]

15.5. Labels

A label is a display area for a short text, an image, or both. It is often used to label other components (usually text fields). Figure 15.15 lists the constructors and methods in JLabel .

Figure 15.15. JLabel displays text or an icon, or both.


[Page 504]

JLabel inherits all the properties from JComponent and has many properties similar to the ones in JButton , such as text , icon , horizontalAlignment , verticalAlignment , horizontalTextPosition , verticalTextPosition , and iconTextGap . For example, the following code displays a label with text and an icon:

 


Introduction to Java Programming-Comprehensive Version
Introduction to Java Programming-Comprehensive Version (6th Edition)
ISBN: B000ONFLUM
EAN: N/A
Year: 2004
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net