1 |
This is an area where text can be displayed in the window.
|
2 |
Create an instance of the Label class and add it to the window:
-
Label label1 = new Label ( "aligned left");
-
add (label1);
|
3 |
Another constructor allows a second argument which is an alignment: Label.LEFT, Label.CENTER, or Label.RIGHT
-
Label label2 = new Label ("aligned right", Label.RIGHT);
|
4 |
Method setText allows you to change the String in the Label, and getText() returns the current String
-
label2.setText("another message");
|
5 |
aligned left aligned right
|