/*
<applet code= "entry.class" width="600" height="300"></applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class entry extends Applet implements ActionListener
{
String s;
Label a1,a2,a3;
TextField b1,b2,b3;
Button c1,c2,c3,c4;
int x,y,z;
public void init()
{
a1=new Label("first no");
a2=new Label("second no");
a3=new Label("result");
b1=new TextField(10);
b2=new TextField(10);
b3=new TextField(10);
c1=new Button("+");
c2=new Button("-");
c3=new Button("*");
c4=new Button("New");
c1.addActionListener(this);
c2.addActionListener(this);
c3.addActionListener(this);
c4.addActionListener(this);
add(a1);
add(b1);
add(a2);
add(b2);
add(a3);
add(b3);
add(c1);
add(c2);
add(c3);
add(c4);
}
public void actionPerformed(ActionEvent xx)
{
if(xx.getSource()==c1)
{
try
{
x=Integer.parseInt(b1.getText());
y=Integer.parseInt(b2.getText());
z=x+y;
b3.setText(String.valueOf(z));
}
catch(Exception e)
{
s="Please check the data";
repaint();
}
}
if(xx.getSource()==c2)
{
x=Integer.parseInt(b1.getText());
y=Integer.parseInt(b2.getText());
z=x-y;
b3.setText(String.valueOf(z));
}
if(xx.getSource()==c3)
{
x=Integer.parseInt(b1.getText());
y=Integer.parseInt(b2.getText());
z=x*y;
b3.setText(String.valueOf(z));
}
if(xx.getSource()==c4)
{
b1.setText("");
b2.setText("");
b3.setText("");
}
}
public void paint(Graphics g)
{
g.drawString("Designed By Abhishek kesharwani",100,300);
g.drawString(s,100,400);
}
}
<applet code= "entry.class" width="600" height="300"></applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class entry extends Applet implements ActionListener
{
String s;
Label a1,a2,a3;
TextField b1,b2,b3;
Button c1,c2,c3,c4;
int x,y,z;
public void init()
{
a1=new Label("first no");
a2=new Label("second no");
a3=new Label("result");
b1=new TextField(10);
b2=new TextField(10);
b3=new TextField(10);
c1=new Button("+");
c2=new Button("-");
c3=new Button("*");
c4=new Button("New");
c1.addActionListener(this);
c2.addActionListener(this);
c3.addActionListener(this);
c4.addActionListener(this);
add(a1);
add(b1);
add(a2);
add(b2);
add(a3);
add(b3);
add(c1);
add(c2);
add(c3);
add(c4);
}
public void actionPerformed(ActionEvent xx)
{
if(xx.getSource()==c1)
{
try
{
x=Integer.parseInt(b1.getText());
y=Integer.parseInt(b2.getText());
z=x+y;
b3.setText(String.valueOf(z));
}
catch(Exception e)
{
s="Please check the data";
repaint();
}
}
if(xx.getSource()==c2)
{
x=Integer.parseInt(b1.getText());
y=Integer.parseInt(b2.getText());
z=x-y;
b3.setText(String.valueOf(z));
}
if(xx.getSource()==c3)
{
x=Integer.parseInt(b1.getText());
y=Integer.parseInt(b2.getText());
z=x*y;
b3.setText(String.valueOf(z));
}
if(xx.getSource()==c4)
{
b1.setText("");
b2.setText("");
b3.setText("");
}
}
public void paint(Graphics g)
{
g.drawString("Designed By Abhishek kesharwani",100,300);
g.drawString(s,100,400);
}
}
No comments:
Post a Comment