|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gnu.glib.Struct
org.gnu.glib.GObject
org.gnu.gtk.GtkObject
org.gnu.gtk.Widget
org.gnu.gtk.Misc
org.gnu.gtk.Label
org.gnome.gtk.Label
.
You should be aware that there is a considerably different API
in the new library: the architecture is completely different
and most notably internals are no longer exposed to public view.
public class Label
The Label widget displays a small amount of text. As the name implies, most labels are used to label another widget such as a Button, a MenuItem, or a OptionMenu.
Labels may contain mnemonics. Mnemonics are underlined characters in the label, used for keyboard navigation. Mnemonics are created by providing a string with an underscore before the mnemonic character, such as "_File", to the constructor or setText method, with the hadMnemonic parameter true.
Mnemonics automatically activate any activatable widget the label is inside, such as a Button; if the label is not inside the mnemonic's target widget, you have to tell the label about the target using setMnemonicWidget.
To make it easy to format text in a label (changing colors, fonts, etc.), label text can be provided in a simple markup format. Here's how to create a label with a small font:
label = new Label(""); label.setMarkup("<small>Small text</small>");(See complete documentation of available tags in the Pango manual.)
The markup passed to setMarkup must be valid; for example, literal </>/& characters must be escaped as <, >, and &. If you pass text obtained from the user, file, or a network to setMarkup, you'll want to escape it with g_markup_escape_text().
Markup strings are just a convenient way to set the PangoAttrList on a label; setAttributes may be a simpler way to set attributes in some cases. Be careful though; PangoAttrList tends to cause internationalization problems, unless you're applying attributes to the entire string . The reason is that specifying the startIndex and endIndex for a PangoAttribute requires knowledge of the exact string being displayed, so translations will cause problems.
Labels can be made selectable with setSelectable. Selectable labels allow the user to copy the label contents to the clipboard. Only labels that contain useful-to-copy information - such as error messages - should be made selectable.
A label can contain any number of paragraphs, but will have performance problems if it contains more than a small number. Paragraphs are separated by newlines or other paragraph separators understood by Pango.
Labels can automatically wrap text if you call setLineWrap.
setJustify sets how the lines in a label align with one another. If you want to set how the label as a whole aligns in its available space, see gtk.Misc.setAlignment.
Constructor Summary | |
---|---|
Label(org.gnu.glib.Handle handle)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
|
Label(java.lang.String caption)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
|
Label(java.lang.String caption,
boolean hasMnemonic)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
Method Summary | |
---|---|
double |
getAngle()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
AttrList |
getAttributes()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
EllipsizeMode |
getEllipsize()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
Justification |
getJustification()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
java.lang.String |
getLabel()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
static Label |
getLabel(org.gnu.glib.Handle handle)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
boolean |
getLineWrap()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
int |
getMaxWidthChars()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
Widget |
getMnemonicWidget()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
boolean |
getSelectable()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
boolean |
getSelected()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
int |
getSelectionEnd()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
int |
getSelectionStart()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
boolean |
getSingleLineMode()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
java.lang.String |
getText()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
static org.gnu.glib.Type |
getType()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
boolean |
getUseMarkup()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
boolean |
getUseMnemonic()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
int |
getWidthChars()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
select(int startOffset,
int endOffset)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setAngle(double angle)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setAttributes(AttrList attributes)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setEllipsize(EllipsizeMode mode)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setJustification(Justification justification)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setLabel(java.lang.String label)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setLineWrap(boolean wrap)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setMarkup(java.lang.String markup)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setMarkup(java.lang.String markup,
boolean hasMnemonic)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setMaxWidthChars(int chars)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setMnemonicWidget(Widget widget)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setSelectable(boolean setting)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setSingleLineMode(boolean singleLineMode)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setText(java.lang.String caption)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setUnderlinePattern(java.lang.String pattern)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setUseMarkup(boolean setting)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setUseMnemonic(boolean setting)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
void |
setWidthChars(int chars)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries. |
Methods inherited from class org.gnu.gtk.Misc |
---|
getXAlign, getXPadding, getYAlign, getYPadding, setAlignment, setPadding |
Methods inherited from class org.gnu.gtk.GtkObject |
---|
destroy, sink |
Methods inherited from class org.gnu.glib.GObject |
---|
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, collect, freezeNotify, getBooleanProperty, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getProperty, getStringProperty, hasProperty, notify, removeEventHandler, removeListener, setBooleanProperty, setData, setDoubleProperty, setFloatProperty, setIntProperty, setJavaObjectProperty, setLongProperty, setProperty, setStringProperty, thawNotify |
Methods inherited from class org.gnu.glib.Struct |
---|
equals, getHandle, getNullHandle, hashCode |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Label(java.lang.String caption)
caption
- The default text to be displayed on the labelpublic Label(java.lang.String caption, boolean hasMnemonic)
caption
- The default text to be displayed on the labelhasMnemonic
- If true, the caption is interpreted to have mnemonic
characters. See the description for this class for more
details.public Label(org.gnu.glib.Handle handle)
Method Detail |
---|
public static Label getLabel(org.gnu.glib.Handle handle)
public void setText(java.lang.String caption)
caption
- the new text to be displayed.public java.lang.String getText()
public void setAttributes(AttrList attributes)
attributes
- Pange attrlist attributes to useAttrList
public AttrList getAttributes()
public void setLabel(java.lang.String label)
label
- The new text to set for the labelpublic java.lang.String getLabel()
public void setMarkup(java.lang.String markup)
markup
which is marked up with the Pango text
markup language, setting the label's text and attribute list based on the
parse results. The markup should not contain mnemonic characters if this
method is used.
markup
- String containing pango markuppublic void setMarkup(java.lang.String markup, boolean hasMnemonic)
markup
which is marked up with the Pango text
markup language, setting the label's text and attribute list based on the
parse results.
markup
- String containing pango markuphasMnemonic
- If true, the markup string will be interpreted to contain
mnemonic characters, for use as keyboard acceleratorspublic void setUseMarkup(boolean setting)
setting
- TRUE if the label's text should be parsed for markup.setMarkup(String, boolean)
public boolean getUseMarkup()
setUseMarkup(boolean)
public boolean getUseMnemonic()
setUseMnemonic(boolean)
public void setUseMnemonic(boolean setting)
setting
- TRUE if underlines in the text indicate mnemonicspublic void setMnemonicWidget(Widget widget)
The target widget will be accelerated by emitting "mnemonic_activate" on it. The default handler for this signal will activate the widget if there are no mnemonic collisions and toggle focus between the colliding widgets otherwise.
widget
- The target widgetpublic Widget getMnemonicWidget()
public void setJustification(Justification justification)
public Justification getJustification()
setJustification(Justification)
public void setUnderlinePattern(java.lang.String pattern)
pattern
- The pattern as described above.public void setLineWrap(boolean wrap)
wrap
- New line wrap setting.public boolean getLineWrap()
public void setSelectable(boolean setting)
setting
- TRUE to allow selecting text in the labelpublic boolean getSelectable()
public void select(int startOffset, int endOffset)
startOffset
- The start offset in charactersendOffset
- The end offset in characterssetSelectable(boolean)
public boolean getSelected()
public int getSelectionStart()
public int getSelectionEnd()
public void setWidthChars(int chars)
chars
- the new desired width, in characters.public int getWidthChars()
setWidthChars(int)
public void setMaxWidthChars(int chars)
chars
- the new desired maximum width, in characters.public int getMaxWidthChars()
setMaxWidthChars(int)
public void setAngle(double angle)
angle
- the angle that the baseline of the label makes with the
horizontal, in degrees, measured counterclockwisepublic double getAngle()
setAngle(double)
public void setSingleLineMode(boolean singleLineMode)
singleLineMode
- true if the label should be in single line modepublic boolean getSingleLineMode()
public void setEllipsize(EllipsizeMode mode)
public EllipsizeMode getEllipsize()
public static org.gnu.glib.Type getType()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |