import
java.awt.*;
import
java.awt.event.*;
import
java.applet.AudioClip;
import
java.applet.*;
/*<applet code
Audio width=400 height=300></applet>*/
public class Audio extends Applet
implements ActionListener
{
Button play,stop;
AudioClip
ac;
int i=0;
public void init()
{
play=new
Button("play");
stop=new Button("stop");
add(play);
add(stop);
ac=getAudioClip(getCodeBase(),"yahoo1.au");
play.addActionListener(this);
stop.addActionListener(this);
}
public void
actionPerformed(ActionEvent ae)
{
String
s=ae.getActionCommand();
if(s.equals("play"))
ac.play();
else
if(s.equals("stop"))
ac.stop();
else
System.out.println("");
}
}
import
java.awt.*;
import
java.applet.*;
import
java.awt.event.*;
/*<applet
code="audio1" width=400 height=300></applet>*/
public class
audio1 extends Applet
{
public void start()
{
try
{
play(getCodeBase(),"1.au");
play(getCodeBase(),"0.au"); }
catch(Exception
e)
{
}
}
}
<html>
<title>ramu.sounds</title>
<applet
code="audio1" width=400 height=300>
</applet>
<body
bgcolor=yellow>
</body>
</html>
import
java.awt.*;
import
java.awt.event.*;
import
java.applet.AudioClip;
import
java.applet.*;
public class
audio2 extends Applet implements ActionListener
{
Button
play,stop;
AudioClip
ac;
int i=0;
public void
init()
{
play=new
Button("play");
stop=new
Button("stop");
add(play);
add(stop);
ac=getAudioClip(getCodeBase(),"yahoo1.au");
play.addActionListener(this);
stop.addActionListener(this);
}
public void
actionPerformed(ActionEvent e)
{
String
s=e.getActionCommand();
if(s.equals("play"))
ac.play();
else
if(s.equals("stop"))
ac.stop();
else
System.out.println("");
}
}
import
java.net.*;
import
java.applet.*;
/*<applet
code=Audioplay.class width=400 height=300></applet> */
public class
Audioplay extends Applet
{
AudioClip
clip;
public void
init()
{
clip=getAudioClip(getCodeBase(),"0.au");
clip.play();
}
public void
start()
{
clip.loop();
}
public void
stop()
{
clip.stop();
}
}
import
java.awt.*;
import
java.applet.*;
/*<applet
code=awaydark width=1200 height=800></applet>*/
public class
awaydark extends Applet
{
public void
paint(Graphics g)
{
for(int
c=0;c<=400;c++)
{
int
x=600,y=450,w=2,h=2;
x=x-(c+1);
y=y-(c+1);
w=w+(c+1);
h=h+(c+1);
g.drawOval(x,y,w,h);
for(int d=0;d<=3;d++);
}}}
<html>
<title>imagedemo1</title>
<applet code=imagedemo1 width=200 height=400></applet>
</html>
import
java.awt.*;
import
java.applet.*;
/*<applet
code=imagedemo1 width=400 height=300></applet>*/
public class
imagedemo1 extends Applet
{
Image i;
public void
init()
{
setBackground(Color.blue);
i=getImage(getCodeBase(),"aish4.jpeg");
}
public void paint(Graphics g)
{
g.drawImage(i,100,100,this);
}
}
import
java.awt.*;
import
java.applet.*;
import
java.awt.event.*;
/*<applet
code=imagedemo2 width=400 height=300></applet>*/
public class
imagedemo2 extends Applet implements ActionListener
{
Image i[];
Button
b1,b2;
int c=0,x,y;
public void
init()
{
setLayout(null);
i=new
Image[20];
setBackground(Color.yellow);
//i[1]=getImage(getCodeBase(),"
background.jpeg ");
i[2]=getImage(getCodeBase(),"Aish4.jpeg
");
//i[3]=getImage(getCodeBase(),"13[2].jpeg
");
//i[4]=getImage(getCodeBase(),"Amisha
Patel 005.jpeg ");
//i[5]=getImage(getCodeBase(),"Amisha
Patel 009.jpeg " );
/*i[6]=getImage(getCodeBase()," ");
i[7]=getImage(getCodeBase()," ");
i[8]=getImage(getCodeBase()," ");
i[9]=getImage(getCodeBase()," ");
i[10]=getImage(getCodeBase()," ");
i[11]=getImage(getCodeBase()," ");
i[12]=getImage(getCodeBase()," ");
i[13]=getImage(getCodeBase()," ");
i[14]=getImage(getCodeBase()," ");
i[15]=getImage(getCodeBase()," ");
i[16]=getImage(getCodeBase()," ");
i[17]=getImage(getCodeBase()," ");
i[18]=getImage(getCodeBase()," ");
i[19]=getImage(getCodeBase()," ");
i[20]=getImage(getCodeBase()," ");
*/
b1=new
Button("<next>");
b2=new
Button("<<previous>>");
b1.setBounds(500,100,40,20);
b2.setBounds(600,100,40,20);
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void
actionPerformed(ActionEvent ae)
{
String
s=ae.getActionCommand();
if(s.equals("<next>"))
c++;
else
if(s.equals("<<prev>>"))
c--;
if(c==10)
c=0;
if(c<0)
c=0;
repaint();
}
public void
paint(Graphics g)
{
x=i[c].getWidth(this);
y=i[c].getWidth(this);
g.drawImage(i[c],600-x/2,400-y/2,this);
}
}
import
java.awt.*;
import
java.awt.event.*;
/* <applet code=imagedemo3 width=1200
height=800></applet> */
public class imagedemo3 extends Frame
{
static Image i;
public imagedemo3()
{
i=Toolkit.getDefaultToolkit().getImage("Aish4.jpeg");
MediaTracker
m=new MediaTracker(this);
m.addImage(i,0);
try
{
m.waitForID(0);
}
catch(InterruptedException
ie){}
addWindowListener(new
WindowAdapter()
{
public
void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}
public void
paint(Graphics g)
{
g.drawImage(i,50,50,null);
}
public
static void main(String s[])
{
imagedemo3
i3=new imagedemo3();
i3.setSize(500,400);
i3.setTitle("my
image");
i3.setIconImage(i);
i3.show();
}}
import
java.util.*;
class random
{
public
static void main(String s[])
{
Random r=new
Random();
for(int
i=0;i<10;i++)
System.out.println(r.nextInt()+"\t"+r.nextFloat()+"\t"+r.nextDouble()+"\t"+r.nextLong()+"\t"+r.nextGaussian());
//r.nextBytes(int
a[]=new int[3]); not working properly
//for(i=0;i<3;i++)
//System.out.println(a[i]);
//r.setSeed(new
long 1000000.0);
//System.out.println("the
out put is "+r);
}
}
import
java.awt.*;
import
java.awt.event.*;
class A
extends Frame
{
String s1=" ";
String s2=" ";
String mx,my;
public A()
{
addKeyListener(new MyKeyAdapter(this));
addMouseListener(new MyMouseAdapter(this));
addWindowListener(new MyWindowAdapter());
}
public void paint(Graphics g)
{
g.setColor(Color.green);
g.drawString(s1,100,400);
g.drawString(s2,100,600);
g.drawString("this is for testing
of the draw string",10,80);
g.drawString(mx,200,200);
g.drawString(my,200,220);
}
public static void main(String s[])
{
A a=new A();
a.setForeground(Color.red);
a.setBackground(Color.pink);
a.setSize(new
Dimension(300,200));
a.setBounds(0,0,600,400);
a.setTitle("this is the
graphics programmin how it works explains");
a.setVisible(true);
}}
class
MyKeyAdapter extends KeyAdapter
{
A aw;
public MyKeyAdapter(A aw)
{
this.aw=aw;
}
public void
keyTyped(KeyEvent ke)
{ String s1=" ";
aw.s1+=ke.getKeyChar();
System.out.println("you entered the keys "+s1);
aw.repaint();
}
public void
keyReleased(KeyEvent ke)
{
String s2="";
s2+=ke.getKeyChar();
System.out.println("you entered the keys "+s2);
aw.repaint();
}
public void
keyPressed(KeyEvent ke)
{
String s3="";
s3+=ke.getKeyChar();
System.out.println("you here key pressed");
System.out.println("you entered the keys "+s3);
aw.repaint();
}
}
class
MyMouseAdapter extends MouseAdapter
{
A aw;
public
MyMouseAdapter(A aw)
{
this.aw=aw;
}
public void
mousePressed(MouseEvent me)
{
aw.mx=Integer.toString(me.getX());
aw.my=Integer.toString(me.getY());
System.out.println("the
cordinates of the x is"+aw.mx+"
"+aw.my);
aw.s2="mousedown
at"+aw.mx+"
"+aw.my;
aw.repaint();
}}
class
MyWindowAdapter extends WindowAdapter
{
public void
windowClosing(WindowEvent we)
{
System.exit(0);
}}
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి