SMILELY & CRIEY programmed in java
--------------------------------------------------------------------------------------
//Back again , this time with SMILELY & CRIEY programmed in java. You can know how to interface init() and paint(). // ..........HAPPY CODINGimport java.io.*;
import java.awt.event.*;
import java.util.Scanner;
import java.awt.*;
import java.applet.*;
/*<applet code="smile" width=150 height=140></applet>*/
public class smile extends Applet implements ActionListener {
int r1,t=0,m;
Button b1;
Button b2,b3;
public void init()
{
Color k=new Color(120,89,90);
setBackground(k);
b1=new Button("PRESS TO GET CRIEY ");
b1.setBounds(1970,2580,160,120);
b1.setBackground(Color.red);
b1.setForeground(Color.blue);
b1.addActionListener(this);
add(b1);
b2=new Button("PRESS TO GET SMIELY ");
add(b2);
//b1.setBounds(970,2580,160,920);
b2.setBackground(Color.red);
b2.setForeground(Color.blue);
b2.addActionListener(this);
b3=new Button("MY WORDS ");
b3.setBounds(1970,2580,160,120);
b3.setBackground(Color.red);
b3.setForeground(Color.blue);
b3.addActionListener(this);
add(b3);
}
public void paint(Graphics g)
{
if(t==0)
{
g.setColor(Color.yellow);
g.fillOval(340,180,250,250);
g.setColor(Color.black);
g.fillOval(390,260,35,35);
g.setColor(Color.black);
g.fillOval(500,260,35,35);
g.setColor(Color.black);
for(int i=0;i<9;i++)
{g.drawArc(400,305,130+i,68+i,180,180);}
g.setColor(Color.yellow);
g.fillOval(740,180,250,250);
g.setColor(Color.black);
g.fillOval(790,260,35,35);
g.setColor(Color.black);
g.fillOval(900,260,35,35);
g.setColor(Color.black);//1300,435
for(int i=0;i<9;i++)
{g.drawArc(800,325,130+i,68+i,0,180);}
for(int i=0;i<6;i++)
g.drawArc(800,325+i,130,68,15,165);
}
if(t==2)
{Color k=new Color(120,89,90);
setBackground(k);
g.setColor(Color.yellow);
g.fillOval(540,180,250,250);
g.setColor(Color.black);
g.fillOval(590,260,35,35);
g.setColor(Color.black);
g.fillOval(700,260,35,35);
g.setColor(Color.black);
for(int i=0;i<9;i++)
{g.drawArc(600,305,130+i,68+i,180,180);}
}
if(t==1)
{Color k=new Color(120,89,90);
setBackground(k);
g.setColor(Color.yellow);
g.fillOval(640,180,250,250);
g.setColor(Color.black);
g.fillOval(690,260,35,35);
g.setColor(Color.black);
g.fillOval(800,260,35,35);
g.setColor(Color.black);//1300,435
for(int i=0;i<9;i++)
{g.drawArc(700,330,130+i,68+i,0,180);}
for(int i=0;i<6;i++)
g.drawArc(700,330+i,130,68,15,165);
}
if(t==3)
{//Color k=new Color(2,3,4);
setBackground(Color.WHITE);
Font font = new Font("Serif", Font.PLAIN, 34);
g.setFont(font);
g.setColor(Color.blue);
g.drawString("THANK YOU ", 550, 180);
g.setColor(Color.CYAN);
g.drawString("FOR ", 610, 230);
g.setColor(Color.GREEN);
g.drawString("WATCHING ", 550, 280);
g.setColor(Color.BLACK);
g.drawString(".....viswadeep ", 850, 450);
}
}
public void actionPerformed( ActionEvent ae) {
String str=ae.getActionCommand();
if (ae.getSource() == b1)
{t=1;
repaint();//calling paint() function
}
if (ae.getSource() == b2)
{t=2;
repaint();//calling paint() function
}
if (ae.getSource() == b3)
{t=3;
repaint();//calling paint() function
}
}
}
No comments:
Post a Comment