Photo Application in java
1]. Import different photos which you want in photo application.
2]. Place photo name in function getImage(getCodeBase(), "acura.jpg"). where photo name is acura.jpg.
3]. Don't forget to add extensions like jpg to your photo name.
............Happy Coding
*********************************************************************************************************************
import java.applet.Applet;
import java.awt.Button;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Set;
public class VisuPhotoApp extends Applet implements ActionListener
{
Image i1;
int i=0,k;
MediaTracker tr;
Button b1 ,b2,b3;
public void init()
{ setLayout(null);
b1 = new Button(" SLIDE SHOW ");
b1.setBounds(650,10,90,30);
b1.addActionListener(this);
b1.setBackground(Color.RED);
b1.setForeground(Color.WHITE);
add(b1);
b2 = new Button(" < PRE ");
b2.setBounds(10,300,70,30);
b2.addActionListener(this);
b2.setBackground(Color.green);
add(b2);
b3 = new Button(" NEXT >");
b3.setBounds(1275,300,70,30);
b3.addActionListener(this);
b3.setBackground(Color.green);
add(b3);
}
public void paint(Graphics g)
{
tr = new MediaTracker(this);
switch (k)
{
case 0:
b2.setVisible(false);
i1 = getImage(getCodeBase(), "acura.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
delay(999999999);
break;
case 1:
{
b2.setVisible(true);b3.setVisible(true);
i1 = getImage(getCodeBase(), "Audi-RS7.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
//delay(999999999);
break;
}
case 2:
{
b2.setVisible(true);b3.setVisible(true);
i1 = getImage(getCodeBase(), "Audi.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
//delay(999999999);
break;
}
case 3:
{
b2.setVisible(true);b3.setVisible(true);
i1 = getImage(getCodeBase(), "honda1.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550,this);
//delay(999999999);
break;
}
case 4:
{
b2.setVisible(true);b3.setVisible(true);
i1 = getImage(getCodeBase(), "Lamborghini-Huracan.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
//delay(999999999);
break;
}
case 5:
{
b2.setVisible(true);b3.setVisible(true);
i1 = getImage(getCodeBase(), "Lamborghini.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
//delay(999999999);
break;
}
case 6:
{
b2.setVisible(true);b3.setVisible(true);
i1= getImage(getCodeBase(), "maybach.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
//delay(999999999);
break;
}
case 7:
{
b3.setVisible(false);b2.setVisible(true);
i1= getImage(getCodeBase(), "McLaren.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
break;
}
case 8:
{
i1 = getImage(getCodeBase(), "acura.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
delay(999999999);
i1 = getImage(getCodeBase(), "Audi-RS7.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
delay(999999999);
i1 = getImage(getCodeBase(), "Audi.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
delay(999999999);
i1 = getImage(getCodeBase(), "honda1.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550,this);
delay(999999999);
i1 = getImage(getCodeBase(), "Lamborghini-Huracan.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
delay(999999999);
i1 = getImage(getCodeBase(), "Lamborghini.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
delay(999999999);
i1 = getImage(getCodeBase(), "maybach.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
delay(999999999);
i1 = getImage(getCodeBase(), "McLaren.jpg");
tr.addImage(i1,0);
g.drawImage(i1, 90,50,1180,550, this);
b3.setVisible(false);
i=7;
break;
}
}
}
public void delay(int y)
{
int p;for(p=0;p<y+55;p++)
{}
}
public void actionPerformed(ActionEvent v) {
//Button2.setVisible(false);b1.setVisible(false);
if (v.getSource() == b1)
{i=8;repaint();}
if (v.getSource() == b2)
{i--;repaint();}
if (v.getSource() == b3)
{i++;repaint();}
}
}