Sunday, February 7, 2016

Program to use setText() and getText() methods of Label.

import java.awt.*;
class Demo3_Label extends Frame
{
public static void main(String args[ ] )
{
Label l1=new Label();
//Setting text of a label
l1.setText("Java is lnteresting!!!");
//Getting text of a label and set it to another label
String lbltext=l1.getText();
Label l2=new Label();
l2.setText(lbltext);
Demo3_Label f1=new Demo3_Label();
f1.setTitle("Adding a Label in a Frame!!!");
f1.add(l2);
f1.resize(300,200);
f1.show( );
}
}
Output:

No comments:

Post a Comment