waba.ui
Class Label

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--waba.ui.Label

public class Label
extends Control

Label is a text label control. It supports multiline, but you need to separate the text with |.

Note: this class does not do automatic parse of the text, because this is a slow operation. But, you can use a handy method to parse the text that you want to display: see the waba.sys.Convert.insertLineBreak method.

Here is an example showing a label being used:

 public class MyProgram extends MainWindow
 {
 public void onStart()
  {
  add(new Label("Value:"), LEFT, TOP);
  }
 


Field Summary
 int align
           
static int commonVGap
          You can set this to 4 so that the labels will have the same height of a WinCE Edit.
protected  java.lang.String text
           
 
Fields inherited from class waba.ui.Control
AFTER, appId, appObj, asContainer, asWindow, backColor, backDis, BEFORE, BOTTOM, CENTER, clearValueInt, clearValueStr, enabled, FILL, FIT, fm, fmH, focusLess, focusTraversable, font, foreColor, foreDis, height, highlightRectsCount, isHighlighting, LEFT, parent, PREFERRED, RANGE, RIGHT, SAME, TOP, uiCE, uiFlat, uiPalm, uiVista, visible, width, x, x2, y, y2
 
Constructor Summary
Label(java.lang.String text)
          Creates a label displaying the given text with left alignment. supports inverted text, multiple lines and is scrollable
Label(java.lang.String text, int align)
          Creates a label displaying the given text with the given alignment.
 
Method Summary
 boolean canScroll(boolean down)
          returns if the label can scroll in the given direction
 void clear()
          This method does nothing: clear a label is not a desired action.
 int getPreferredHeight()
          returns the preffered width of this control. added by guich
 int getPreferredWidth()
          returns the preffered width of this control. added by guich
 java.lang.String getText()
          Gets the text that is displayed in the label.
protected  void onBoundsChanged()
          Called after a setRect.
protected  void onColorsChanged(boolean colorsChanged)
          Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container.
protected  void onFontChanged()
          Called after a setFont
 void onPaint(Graphics g)
          Called by the system to draw the button.
 boolean scroll(boolean down)
          scroll one page. returns true if success, false if no scroll possible
 void set3d(boolean on)
          if 3d is true, draws the label with a 3d effect. turns off invert.
 void setInvert(boolean on)
          if invert is true, the back and fore color are swaped. turns off 3d.
 void setText(java.lang.String text)
          Sets the text that is displayed in the label.
 
Methods inherited from class waba.ui.Control
addTimer, changeHighlighted, contains, createGraphics, drawHighlight, getAbsoluteRect, getBackColor, getFont, getFontMetrics, getForeColor, getNext, getParent, getParentWindow, getPos, getRect, getSize, isDisplayed, isEnabled, isVisible, onEvent, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, requestFocus, setBackColor, setBackForeColors, setEnabled, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setVisible, translateFromOrigin, uiStyleChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

text

protected java.lang.String text

align

public int align

commonVGap

public static int commonVGap
You can set this to 4 so that the labels will have the same height of a WinCE Edit. Don't forget to reset it to the default, zero. Since SuperWaba 4.01
Constructor Detail

Label

public Label(java.lang.String text)
Creates a label displaying the given text with left alignment. supports inverted text, multiple lines and is scrollable

Label

public Label(java.lang.String text,
             int align)
Creates a label displaying the given text with the given alignment.
Parameters:
text - the text displayed
align - the alignment
See Also:
Control.LEFT, Control.RIGHT, Control.CENTER
Method Detail

set3d

public void set3d(boolean on)
if 3d is true, draws the label with a 3d effect. turns off invert.

setInvert

public void setInvert(boolean on)
if invert is true, the back and fore color are swaped. turns off 3d.

setText

public void setText(java.lang.String text)
Sets the text that is displayed in the label.

getText

public java.lang.String getText()
Gets the text that is displayed in the label.

getPreferredWidth

public int getPreferredWidth()
returns the preffered width of this control. added by guich
Overrides:
getPreferredWidth in class Control

getPreferredHeight

public int getPreferredHeight()
returns the preffered width of this control. added by guich
Overrides:
getPreferredHeight in class Control

onColorsChanged

protected void onColorsChanged(boolean colorsChanged)
Description copied from class: Control
Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. If colorsChanged is true, it was called from setForeColor/setBackColor/Container.add; otherwise, it was called from setEnabled
Overrides:
onColorsChanged in class Control

onFontChanged

protected void onFontChanged()
Description copied from class: Control
Called after a setFont
Overrides:
onFontChanged in class Control

onBoundsChanged

protected void onBoundsChanged()
Description copied from class: Control
Called after a setRect.
Overrides:
onBoundsChanged in class Control

canScroll

public boolean canScroll(boolean down)
returns if the label can scroll in the given direction

scroll

public boolean scroll(boolean down)
scroll one page. returns true if success, false if no scroll possible

onPaint

public void onPaint(Graphics g)
Called by the system to draw the button.
Overrides:
onPaint in class Control
Tags copied from class: Control
Parameters:
g - the graphics object for drawing
See Also:
Graphics

clear

public void clear()
This method does nothing: clear a label is not a desired action. If you really want to clear it, set its clearValueStr to "".
Overrides:
clear in class Control