Wednesday, March 30, 2011

Java Applat 03

//Dharmendra Bagrecha
import java.awt.*;
import java.applet.*;
/*
<APPLET code="cal.class" width=400 height=400>
</Applet>
*/
public class cal extends Applet
{
TextField text1,text2;
//Button c;
    public void init()
    {
    text1 = new TextField(5);
    text2 = new TextField(5);
    add(text1);
    add(text2);
    text1.setText("0");
    text2.setText("0");
    //c = new Button("Calculate");
    //c.addActionListener(this);
    }
   
    public void paint(Graphics g)
    {
    int x=0,y=0,z=0;
    String s1,s2,s;
    g.drawString("Input Number in boxes :",10,50);
    try
        {
        s1 = text1.getText();
        x = Integer.parseInt(s1);
        s2 = text2.getText();
        y = Integer.parseInt(s2);
        }
    catch(Exception ex){}
    z = x + y;
    s = String.valueOf(z);
    g.drawString("The Sum is :",10,75);
    g.drawString(s,100,75);
    z = x - y;
    s = String.valueOf(z);
    g.drawString("The Minus is :",10,85);
    g.drawString(s,100,85);
    z = x * y;
    s = String.valueOf(z);
    g.drawString("The Multiply is :",10,95);
    g.drawString(s,100,95);
    }
   
    public boolean action (Event event,Object object)
    {
    repaint();
    return true;
    }
}


Java Applat 02

//Dharmendra Bagrecha
import java.awt.*;
import java.applet.*;
/*
<APPLET code="Face.class" width=200 height=200>
</Applet>
*/
public class Face extends Applet
{
    public void paint(Graphics g)
    {
    g.drawOval(40,40,120,120);
    g.drawOval(57,75,30,20);        //eyes
    g.drawOval(110,75,30,20);
    g.fillOval(68,81,10,10);
    g.fillOval(120,81,10,10);
    g.drawOval(94,100,15,30);        //Nose
    g.drawArc(60,105,80,40,180,180);    //Mouth
    }
}


Popular Posts