public class Label extends StyledWidget
This example shows a simple label:
Label label = new Label("Hello World");
This example shows a styled label:
Label styledLabel = new Label("Hello World"); EditableStyle labelStyle = new EditableStyle(); labelStyle.setForegroundColor(Colors.NAVY); labelStyle.setBackgroundColor(Colors.CYAN); labelStyle.setFontProfile(new FontProfile("", 23, Font.STYLE_PLAIN)); styledLabel.mergeStyle(labelStyle);
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
Label()
Creates a label with an empty text.
|
Label(java.lang.String text)
Creates a label with the given text to display.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getText()
Gets the displayed text of this label.
|
void |
renderContent(ej.microui.display.GraphicsContext g,
Style style,
Rectangle bounds)
Renders the content of the renderable without the border, margin and padding specified in the style.
|
void |
setText(java.lang.String text)
Sets the text to display for this label.
|
void |
updateText(java.lang.String text)
Updates the text to display for this label without asking for repaint.
|
Rectangle |
validateContent(Style style,
Rectangle availableSize)
Gets the content size of the renderable without the border, margin and padding specified in the style.
|
addClassSelector, contains, gainFocus, getAttribute, getChild, getChildrenCount, getChildrenElements, getContentBounds, getParentElement, getStyle, hasClassSelector, isInState, isTransparent, lostFocus, mergeStyle, removeAllClassSelectors, removeClassSelector, removeInstanceStyle, render, setClassSelectors, setEnabled, updateStyle, updateStyleOnly, validate
getAbsoluteX, getAbsoluteX, getAbsoluteY, getAbsoluteY, getEventHandler, getHeight, getPanel, getParent, getPreferredHeight, getPreferredWidth, getRelativeX, getRelativeY, getWidgetAt, getWidth, getX, getY, handleEvent, hasFocus, hideNotify, invalidate, isEnabled, isShown, isValid, isVisible, repaint, repaint, requestFocus, requestFocus, revalidate, revalidateSubTree, setBounds, setEventHandler, setLocation, setPreferredSize, setSize, setVisible, showNotify
public Label()
public Label(java.lang.String text)
text
- the text to display, it cannot be null
.java.lang.NullPointerException
- if the text is null
.public void setText(java.lang.String text)
text
- the text to display, it cannot be null
.java.lang.NullPointerException
- if the text is null
.updateText(String)
public void updateText(java.lang.String text)
text
- the text to display, it cannot be null
.java.lang.NullPointerException
- if the text is null
.public java.lang.String getText()
public void renderContent(ej.microui.display.GraphicsContext g, Style style, Rectangle bounds)
StyledRenderable
The given graphics context is translated and clipped according to the given bounds (the border, margin and padding are applied on this graphics context before).
g
- the graphics context where to render the content of the renderable.style
- the style to use.bounds
- the remaining size to render the content.Outline.apply(GraphicsContext, Rectangle)
,
Border.apply(GraphicsContext, Rectangle, int)
,
StyleHelper.renderWithoutContent(GraphicsContext, Rectangle, Style)
public Rectangle validateContent(Style style, Rectangle availableSize)
StyledRenderable
style
- the style to use.availableSize
- the bounds available for the content. A width or a height equals to MWT.NONE
means no
constraint on this dimension.