import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class FinalExam extends JApplet implements ActionListener {
JButton SwapButton ;
JButton SwapOrigButton ;
private Image party;
private Image party2;
private Image load;
private AudioClip mcdClip;
final int width = 150, height = 300;
public void init() {
party = getImage(getDocumentBase(), " Party.jpg ");
party2 = getImage(getDocumentBase(), " Party2.jpg ");
load = getImage(getDocumentBase(), " load.jpg ");
mcdClip = getAudioClip(getCodeBase(), "indy.mid");
setBackground(Color.blue);
}
public FinalExam()
{
SwapButton = new JButton("Swap New Image");
SwapOrigButton = new JButton("Swap Old Image");
SwapButton.setActionCommand( "swap" );
SwapOrigButton.setActionCommand( "swap2" );
getContentPane().setLayout( new FlowLayout() );
getContentPane().add( SwapButton );
getContentPane().add( SwapOrigButton );
SwapButton.addActionListener( this );
SwapOrigButton.addActionListener( this );
SwapButton.repaint();
SwapOrigButton.repaint();
}
public void actionPerformed( ActionEvent evt )
{
Graphics g = getGraphics();
if ( evt.getActionCommand().equals( "swap" ) ){
g.drawImage(party2, 500, 0, this);
}
if ( evt.getActionCommand().equals( "swap2" ) ){
g.drawImage(party, 500, 0, this);
}
}
public void paint(Graphics g){
g.setFont(new Font("Rage Italic",Font.PLAIN,15));
g.setColor(new Color(255, 255, 255 ));
g.drawString("Dear Guest,", 50, 65);
g.setFont(new Font("Serif",Font.PLAIN, 15));
g.setColor(new Color(255, 255, 0 ));
g.drawString(" As you may or may not know I, Neal Cobert, am holding a 2 day", 70, 80);
g.setFont(new Font("Serif",Font.BOLD, 15));
g.setColor(new Color(255, 255, 0 ));
g.drawString("Anti-Prom Party...YAY!!!", 50, 100);
g.setFont(new Font("Times New Roman",Font.PLAIN, 15));
g.setColor(new Color(193, 255, 193 ));
g.drawString(" Now if you have been invited then you may come.", 70, 120);
g.drawString("However if you did not recieve an invite from me personally than", 50, 135);
g.setFont(new Font("Times New Roman",Font.ITALIC, 15));
g.setColor(new Color(193, 255, 193 ));
g.drawString("you may not come. :D", 50, 150);
g.setFont(new Font("Rockwell",Font.BOLD, 20));
g.setColor(new Color(162, 205, 90));
g.drawString("Who: ME!!!", 50, 200);
g.drawString("What: ANTI-PROM PARTY!!!", 50, 220);
g.drawString("Where: MY HOUSE :)", 50, 240);
g.drawString("When: Prom Weekend", 50, 260);
g.drawString("Why: Why Not", 50, 280);
g.setColor(Color.black);
g.fillRect(150,300,200,150);
g.setColor(Color.lightGray);
g.fillRect(160,310,180,130);
g.setColor(Color.black);
g.drawLine(300,300,400,210);
g.drawLine(150,210,300,300);
g.drawImage(party, 500, 0, this);
g.drawString("Indiana Jones", 700, 400);
int count = 0 ;
while ( count < 10 )
{
int diameter = width/10;
int X = count*diameter; // the left edge of each square
int Y = height/2 - diameter/2; // the top edge of the squares
g.drawImage(load, X, +4, diameter, diameter, this );
count = count + 1;
}
}
public void Stop(){
mcdClip.stop();
}
public void start() {
mcdClip.loop();
}
}