import java.awt.Color;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Album extends Applet implements ActionListener{
private Button next = new Button("NEXT");
private Button back = new Button("BACK");
private Button exit = new Button("X");
private Label titel = new Label(" ");
private Label comments = new Label(" ");
private String[] name = new String[6];
private String[] comment = new String[6];
private Label label = new Label("Istoriata na loshoto momche Kolovati s snimki.");
int i = 0;
public void init() {
setBackground(new Color(0,109,255));
setSize(300,300);
name[0] = (" 1999.jpg");
name[1] = (" 2001.jpg");
name[2] = (" 2002.jpg");
name[3] = (" 2003.jpg");
name[4] = (" 2004.jpg");
name[5] = (" 2005.jpg");
comment[0] = (" Gorkia nqmal e kakvo da qde i obleche.");
comment[1] = ("Kolovati trenira za Biad da se napie bezpametno");
comment[2] = ("Iliancho sled kato e naplqskal treniora Chuguna");
comment[3] = (" V Levski e nqmal daje pari da se postrije.");
comment[4] = (" Sled napivane v rodnia mu grad Kustendil.");
comment[5] = ("Kolovati sled parvoto zemetresenie v Japonia.");
setLayout(null);
back.addActionListener(this);
back.setSize(50,20);
back.setLocation(0,25);
next.addActionListener(this);
next.setSize(50,20);
next.setLocation(250,25);
titel.setSize(100,20);
titel.setLocation(110,25);
comments.setSize(280,20);
comments.setLocation(15,260);
exit.setSize(20,20);
exit.setLocation(280,0);
exit.addActionListener(this);
label.setBackground(Color.BLUE);
label.setForeground(new Color(244,211,68));
label.setFont(new Font("Serif", Font.BOLD, 13));
label.setSize(270,15);
label.setLocation(2,2);
add(label);
add(exit);
//add(back);
add(titel);
add(next);
add(comments);
}
public void paint(Graphics g) {
g.setColor(Color.BLUE);
g.fillRect(0,0,280,20);
titel.setText(name[i]);
Image image = getImage(getDocumentBase(), name[i]);
g.drawImage(image,75,50,this);
comments.setText(comment[i]);
}
public void actionPerformed(ActionEvent e) {
if(name[i]==0){
add(back);
}
else if (i==5) {
add(back);
remove(next);
}
if(e.getSource() == exit) {
System.exit(0);
}
if(e.getSource()== next){
i=(i+1)%name.length;
}
if(e.getSource()==back){
i=i-1;
if(i<0){
i=(i+name.length)%name.length;
}
}
repaint();
}
}