import java.awt.*;
import java.awt.event.*;
import java.applet.*;
//<applet code="textinput" width=500 height=300></applet>
public class textinput extends Applet implements ActionListener
{
Font f=new Font("TimesRoman",Font.BOLD,30);
TextField t1,t2;
Button b1;
Label l1;
public void init()
{
setBackground(Color.pink);
setForeground(Color.blue);
t1=new TextField(8);
t2=new TextField(8);
b1=new Button("Ok");
setFont(f);
l1=new Label("Enter a Number");
add(l1);
add(t1);
add(t2);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
int n, r,rev=0;
String s1;
s1=t1.getText();
n=Integer.parseInt(s1);
while(n!=0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
String x=String.valueOf(rev);
t2.setText(x);
}
}
}
import java.awt.event.*;
import java.applet.*;
//<applet code="textinput" width=500 height=300></applet>
public class textinput extends Applet implements ActionListener
{
Font f=new Font("TimesRoman",Font.BOLD,30);
TextField t1,t2;
Button b1;
Label l1;
public void init()
{
setBackground(Color.pink);
setForeground(Color.blue);
t1=new TextField(8);
t2=new TextField(8);
b1=new Button("Ok");
setFont(f);
l1=new Label("Enter a Number");
add(l1);
add(t1);
add(t2);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
int n, r,rev=0;
String s1;
s1=t1.getText();
n=Integer.parseInt(s1);
while(n!=0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
String x=String.valueOf(rev);
t2.setText(x);
}
}
}
No comments:
Post a Comment