Label
This control is used to display static text or a marquee. The label in TotalCross can also display multiple lines of text, separated by the character.
Last updated
Was this helpful?
This control is used to display static text or a marquee. The label in TotalCross can also display multiple lines of text, separated by the character.
Last updated
Was this helpful?
Was this helpful?
package com.totalcross;
import totalcross.sys.Settings;
import totalcross.ui.Label;
import totalcross.ui.MainWindow;
public class LabelSample extends MainWindow {
public LabelSample(){
setUIStyle(Settings.MATERIAL_UI);
Settings.uiAdjustmentsBasedOnFontHeight= true;
}
public void initUI(){
Label helloWord = new Label("Hello World!");
//helloWord.setText("text");
add(helloWord, CENTER, CENTER);
}
}package com.totalcross;
import totalcross.sys.Settings;
import totalcross.ui.Label;
import totalcross.ui.MainWindow;
import totalcross.ui.gfx.Color;
public class LabelSample extends MainWindow{
public LabelSample(){
setUIStyle(Settings.MATERIAL_UI);
Settings.uiAdjustmentsBasedOnFontHeight = true;
}
public void initUI(){
Label lb1, lb2, lb3, lb4;
lb1 = new Label("This is a Simple Label", CENTER);
lb1.setBackForeColors(Color.BLUE, Color.WHITE);
add(lb1, CENTER, CENTER, PARENTSIZE + 70, PREFERRED + 20);
lb2 = new Label("This is a 3D Label", CENTER);
lb2.setBackForeColors(Color.BLUE, Color.WHITE);
lb2.set3d(true);
add(lb2, CENTER, AFTER + 20, SAME, SAME);
lb3 = new Label("This is a Inverted Label", CENTER);
lb3.setBackForeColors(Color.BLUE, Color.WHITE);
lb3.setInvert(true);
add(lb3, CENTER, AFTER + 20, SAME, SAME);
lb4 = new Label("This is a Label with a large text and line break", CENTER);
lb4.setBackForeColors(Color.BLUE, Color.WHITE);
lb4.autoSplit = true;
add(lb4, CENTER, AFTER + 20, SAME, 50);
}
}