Tuesday, February 9, 2016

Program to use various methods of TextField.

import java.awt.*;
class txtFieldMethods extends Frame
{
public static void main(String args[])
{
TextField t1 =new TextField(50);
TextField t2=new TextField(50);
TextField t3=new TextField(50);
TextField t4=new TextField(50);
//To make a TextField Read Only
t1.setEditable(false);
//setting the initial Text of a TextField
t2.setText("Java is Interesting");
//Getting the text of a TextField and stone into a String Object
String str=t2.getText();
//setting the Copied text into nother TextField
t3.setText("Copied Suing is : "+str);
//setting llsking chlacter of a TextField
t4.setEchoCharacter('*');
txtFieldMethods f1=new txtFieldMethods();
f1.setTitle("Adding a TextField in a FIame!!!");
f1.setLayout(new FlowLayout());
f1.add(t1);
  f1.add(t2);
f1.add(t3);
f1.add(t4);
f1.setSize(500,500);
f1.setVisible(true );
}
}
Output:

No comments:

Post a Comment