LABEL:-
A label is an object of type Label, and it contains a string, which it displays. Labels are passive controls that do not support any interaction with the user. Label defines the following constructors:
1. Label( )
2. Label(String str)
3. Label(String str, int how)
1. The first version creates a blank label.
2. The second version creates a label that contains the string specified by str. This string is left-justified.
3. The third version creates a label that contains the string specified by str using the alignment specified by how.
The value of how must be one of these three constants:
Label.LEFT, Label.RIGHT, or Label.CENTER.
PROGRAM CODE:-
// Demonstrate Labels
import java.awt.*;
import java.applet.*;
/*
<applet code="LabelDemo" width=300 height=200>
</applet>
*/
public class LabelDemo extends Applet {
public void init() {
Label one = new Label("sateesh");
Label two = new Label("bagadhi");
Label three = new Label("java");
// add labels to applet window
add(one);
add(two);
add(three);
}
}
A label is an object of type Label, and it contains a string, which it displays. Labels are passive controls that do not support any interaction with the user. Label defines the following constructors:
1. Label( )
2. Label(String str)
3. Label(String str, int how)
1. The first version creates a blank label.
2. The second version creates a label that contains the string specified by str. This string is left-justified.
3. The third version creates a label that contains the string specified by str using the alignment specified by how.
The value of how must be one of these three constants:
Label.LEFT, Label.RIGHT, or Label.CENTER.
// Demonstrate Labels
import java.awt.*;
import java.applet.*;
/*
<applet code="LabelDemo" width=300 height=200>
</applet>
*/
public class LabelDemo extends Applet {
public void init() {
Label one = new Label("sateesh");
Label two = new Label("bagadhi");
Label three = new Label("java");
// add labels to applet window
add(one);
add(two);
add(three);
}
}