Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- Label Control
- ~~~~~~~~~~~~~
- public static final int LEFT;
- public static final int CENTER;
- public static final int RIGHT;
- Constructors:-
- Label();
- Label(String);
- Label(String,int);
- Methods:-
- public int getAlignment();
- public synchronized void setAlignment(int);
- public String getText();
- public void setText(String);
- */
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Label;
- /*
- <applet CODE = "LabelDemo" Height = 400 Width = 500>
- </applet>
- */
- public class LabelDemo extends Applet
- {
- public void init()
- {
- Label l1 = new Label("ONE");
- Label l2 = new Label("Two");
- Label l3 = new Label("3", Label.RIGHT);
- add(l1);
- add(l2);
- add(l3);
- l1.setBackground(Color.blue);
- l1.setForeground(Color.yellow);
- }
- }

Post new comment