Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Create labels and display in applet

  1. /*
  2. Label Control
  3. ~~~~~~~~~~~~~
  4.         public static final int LEFT;
  5.         public static final int CENTER;
  6.         public static final int RIGHT;
  7. Constructors:-
  8.         Label();
  9.         Label(String);
  10.         Label(String,int);
  11. Methods:-
  12.         public int getAlignment();
  13.         public synchronized void setAlignment(int);            
  14.         public String getText();
  15.         public void setText(String);
  16. */
  17. import java.applet.Applet;
  18. import java.awt.Color;
  19. import java.awt.Label;
  20.  
  21. /*
  22. <applet CODE = "LabelDemo" Height = 400 Width = 500>
  23. </applet>
  24. */
  25.  
  26. public class LabelDemo extends Applet
  27. {
  28.  public void init()
  29.  {
  30.   Label l1 = new Label("ONE");
  31.   Label l2 = new Label("Two");
  32.   Label l3 = new Label("3", Label.RIGHT);
  33.   add(l1);
  34.   add(l2);
  35.   add(l3);
  36.   l1.setBackground(Color.blue);
  37.   l1.setForeground(Color.yellow);
  38.  }
  39. }
Your rating: None Average: 2 (1 vote)
Share this

Post new comment

18 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.