|
java-gnome version 4.0.7 | ||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||
java.lang.Objectorg.freedesktop.bindings.Proxy
org.gnome.glib.Object
org.gnome.gtk.Object
org.gnome.gtk.Widget
org.gnome.gtk.Misc
org.gnome.gtk.Label
public class Label
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.gnome.gtk.Widget |
|---|
Widget.BUTTON_PRESS_EVENT, Widget.BUTTON_RELEASE_EVENT, Widget.ENTER_NOTIFY_EVENT, Widget.EXPOSE_EVENT, Widget.FOCUS_IN_EVENT, Widget.FOCUS_OUT_EVENT, Widget.HIDE, Widget.KEY_PRESS_EVENT, Widget.KEY_RELEASE_EVENT, Widget.LEAVE_NOTIFY_EVENT, Widget.UNMAP_EVENT, Widget.VISIBILITY_NOTIFY_EVENT |
| Constructor Summary | |
|---|---|
Label(java.lang.String text)
Create a Label with the specified text. |
|
| Method Summary | |
|---|---|
double |
getAngle()
Get the current angle of the Label. |
Justification |
getJustify()
Gets the justification of the text within the Label. |
java.lang.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. |
java.lang.String |
getText()
Get the text showing in the Label, but with any Pango markup stripped away. |
boolean |
getUseMarkup()
Get the current setting indicating whether the the label text is to be interpreted as marked up with Pango's text markup language. |
void |
selectRegion(int start,
int end)
Select a region of the text in this Label. |
void |
setAngle(double angle)
Sets the angle of rotation for the Label. |
void |
setJustify(Justification justification)
Sets the justification of the text within the Label. |
void |
setLabel(java.lang.String text)
Set the text showing in the Label. |
void |
setLineWrap(boolean setting)
Set whether this Label will attempt to wrap the text provided. |
void |
setMaxWidthChars(int width)
Set a maximum width for the Label, in characters. |
void |
setSelectable(boolean setting)
Whether the text in this Label can be selected by the user. |
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. |
void |
setWidthChars(int width)
Explicitly set the width of the Label, in characters. |
| Methods inherited from class org.gnome.gtk.Misc |
|---|
getAlignmentX, getAlignmentY, getPaddingX, getPaddingY, setAlignment, setPadding |
| Methods inherited from class org.gnome.gtk.Widget |
|---|
activate, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getHasFocus, getParent, getRequisition, getToplevel, getWindow, grabFocus, hide, modifyBackground, modifyText, setCanFocus, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll |
| Methods inherited from class org.freedesktop.bindings.Proxy |
|---|
toString |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Label(java.lang.String text)
setUseMarkup(true).
text - the text you wish on the Label.| Method Detail |
|---|
public double getAngle()
public Justification getJustify()
public java.lang.String getLabel()
getText() which
returns the text unadorned.
public java.lang.String getText()
getLabel().
public boolean getUseMarkup()
public void selectRegion(int start,
int end)
start up to but not including end
will be selected. This assumes that the Label has been made selectable
with setSelectable(true).
end - If negative, then the selection will be from
start to the end of the text in the Label.public void setAngle(double angle)
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°.public void setJustify(Justification justification)
LEFT. Note that this has no effect on
Labels only containing a single line of text.
If you're trying to control the positioning of the Label within its
parent, see Misc's
setAlignment().
public void setLabel(java.lang.String text)
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.public void setLineWrap(boolean setting)
setSizeRequest().
The default is false.
public void setMaxWidthChars(int width)
width but
not to expand beyond that point. This is useful in conjunction with
turning
setEllipsize()
on.
This sets the max-width-chars property.
Warning: If a value greater than -1 has been
explicitly set as the width using
setWidthChars(), setting this property
will have no effect.
width - The width you wish to truncate the Label at, in characters.
A value of -1 to remove the override and
return the Label to automatic sizing.public void setSelectable(boolean setting)
public void setUseMarkup(boolean setting)
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.public void setWidthChars(int width)
This sets the width-chars property. Note that if set, this
will take precedence over the max-width-chars property as
set by setMaxWidthChars().
This is not precisely reliable as a way to enforce sizing across
different Labels, since the character sizes could be different owing to
differing languages or fonts that may be in use. Still, this is
superior to trying to manually control Widget size by specifying the
horizontal dimension in pixels. If you need a series of Widgets (be
they Labels or otherwise) to have the same size, apply a
SizeGroup.
width - The width to base the size of the Label on, in characters. A
value of -1 will turn off the override, and
return the Label to automatically sizing based on the
content within and the max-width property, if
activated.
|
![]() java-gnome |
||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||