org.gnome.gtk

Class Label


public class Label
extends Misc

A Widget that displays a small amount of text.

Labels are the backbone of any Window. They are frequently used to identify other controls with names, as headings in Windows, and are the building blocks that Menus and Buttons are made up of. All the difficult parts about rendering text are taken care of here, such as text direction, fonts. And, of course, you can enable them to allow their text to be copied.

Labels can display normal text or text that has been formatted with Pango markup. FIXME with a reference to our Pango guide page.

Although you can pack multiple lines into a Label, there does come a point when the amount of text you're trying to show gets out of hand. At that point you might want to investigate the TextView Widget.

Authors:
Andrew Cowie
Srichand Pendyala
Since:
4.0.1

Nested Class Summary

Nested classes/interfaces inherited from class org.gnome.gtk.Widget

Widget.ENTER_NOTIFY_EVENT, Widget.FOCUS_OUT_EVENT

Constructor Summary

Label(String text)
Create a Label with the specified text.

Method Summary

double
getAngle()
Get the current angle of the Label.
String
getLabel()
Get the text showing in the Label, including any characters which indicate Pango markup syntax and embedded mnemonic underline characters that may be present.
String
getText()
Get the text showing in the Label, but with any Pango markup stripped away.
void
setAngle(double angle)
Sets the angle of rotation for the Label.
void
setLabel(String text)
Set the text showing in the Label.
void
setUseMarkup(boolean setting)
Set whether the text showing in the Label is to be parsed as containing markup in Pango's text markup language.

Methods inherited from class org.gnome.gtk.Widget

connect, connect, getParent, show, showAll

Methods inherited from class org.freedesktop.bindings.Proxy

toString

Constructor Details

Label

public Label(String text)
Parameters:
text - the text you wish on the Label.
Since:
4.0.1

Method Details

getAngle

public double getAngle()
Get the current angle of the Label. An angle of 90° means the text reads in an upwards direction (ie from bottom to top), whereas an angle of 270° means the text reads in a downwards direction (ie from top to bottom).
Since:
4.0.1

getLabel

public String getLabel()
Since:
4.0.1

getText

public String getText()
Since:
4.0.1

setAngle

public void setAngle(double angle)
Sets the angle of rotation for the Label. The angle is measured in degrees from the horizontal, going counter-clockwise. An angle of 90° reads from bottom to top, an angle of 270° from top to bottom. The angle setting for the Label will be ignored if the Label is selectable, wrapped, or ellipsized.
Parameters:
angle - The angle that the baseline of the Label's text makes with the horizontal. The valid range (as you'd expect) is from 0° through 360°.
Since:
4.0.1

setLabel

public void setLabel(String text)
Set the text showing in the Label.
Parameters:
text - If the Label has been told to interpret Pango markup with setUseMarkup(true), then any markup included in text will be interpreted as such.
Since:
4.0.1

setUseMarkup

public void setUseMarkup(boolean setting)
Set whether the text showing in the Label is to be parsed as containing markup in Pango's text markup language. Using this allows Labels to be created with expressive formatting considerably more advanced than a simple line of text.
Parameters:
setting - If setting is true, then any markup included in the text is interpreted as such. If its set to false, markup is ignored and included as-is.
Since:
4.0.1