Package ej.widget.basic
Class Label
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.widget.basic.Label
-
- Direct Known Subclasses:
Button
public class Label extends ej.mwt.Widget
A label is a widget that displays a text.This example shows a simple label:
Label label = new Label("Hello World");
This example shows a styled label:
Label label = new Label("Hello World"); CascadingStylesheet stylesheet = new CascadingStylesheet(); desktop.setStylesheet(stylesheet); EditableStyle labelStyle = stylesheet.getSelectorStyle(new TypeSelector(Label.class)); labelStyle.setColor(Colors.NAVY); labelStyle.setBackground(new RectangularBackground(Colors.CYAN)); labelStyle.setFont(Font.getFont("/fonts/source_sans_pro_24.ejf"));
-
-
Constructor Summary
Constructors Modifier Constructor Description Label()
Creates a label with an empty text.Label(java.lang.String text)
Creates a label with the given text to display.protected
Label(java.lang.String text, boolean enabled)
Creates a label with the given text to display and its enabled state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
computeContentOptimalSize(ej.mwt.util.Size size)
java.lang.String
getText()
Gets the text displayed on this label.protected void
renderContent(ej.microui.display.GraphicsContext g, int contentWidth, int contentHeight)
void
setText(java.lang.String text)
Sets the text to display on this label.-
Methods inherited from class ej.mwt.Widget
addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getContentBounds, getDesktop, getHeight, getParent, getStyle, getWidgetAt, getWidth, getX, getY, handleEvent, hasClassSelector, isAttached, isEnabled, isInState, isShown, isTransparent, onAttached, onDetached, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle, updateStyle
-
-
-
-
Constructor Detail
-
Label
public Label()
Creates a label with an empty text.
-
Label
public Label(java.lang.String text)
Creates a label with the given text to display.- Parameters:
text
- the text to display.
-
Label
protected Label(java.lang.String text, boolean enabled)
Creates a label with the given text to display and its enabled state.- Parameters:
text
- the text to display.enabled
-true
if this label is to be enabled,false
otherwise.
-
-
Method Detail
-
getText
public java.lang.String getText()
Gets the text displayed on this label.- Returns:
- the text displayed on this label.
-
setText
public void setText(java.lang.String text)
Sets the text to display on this label.- Parameters:
text
- the text to display on this label.
-
renderContent
protected void renderContent(ej.microui.display.GraphicsContext g, int contentWidth, int contentHeight)
- Specified by:
renderContent
in classej.mwt.Widget
-
computeContentOptimalSize
protected void computeContentOptimalSize(ej.mwt.util.Size size)
- Specified by:
computeContentOptimalSize
in classej.mwt.Widget
-
-