Java Programming and Multimedia Tutorial



E08  Java Programming and Multimedia
Kiley McDaniel, P.V.N.C. CDSB
Learn how to drive your ICS3M and ICS4M students to learn OOP and Java programming (applets and applications) by incorporating multimedia into your labs. Students can meet all the specific expectations and have fun at the same time. Session will feature use of JDK ver1.3 and JCreator ver1.52 as IDE. Online resources and tutorial available : http://kdoginc.hypermart.net
Audience: S PS
Strand: Computer Studies/Science
Audience Prerequisite:Computer programming and HTML skills
Computer: WIN

Java Applet Multimedia Projects


Multimedia Easter Egg Demo


Download Easter Egg source
/*
*********************************************************
*                                                                     
*                                                                     
*     Multimedia in Java                                      
*    Computer and Information Science                
*    Procedural Java = before thinking OOP         
*     2012 Goal :  update using Java OOP and MVC                                                                
*                                                                     
*                                                                    
*    Lab #8 :  Halloween      Date:  Oct 31/2002  
*                                                                    
*******************************************************/
   import java.applet.*;
   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.net.*;
   public class Halloween implements ActionListener, Runnable
   {
   //ARRAY CODE       
      ImageIcon[] images=new ImageIcon[3];
       
      AudioClip[] audioclip= new AudioClip[2];
        
      int frame= 1;
      int button= 2;
   // Intro of buttons        
      Button bwitch=new Button("WITCH");
      Button bghost=new Button("GHOST");
      volatile Thread thread;
      JFrame jframe = new JFrame("Application version");
      Drawing draw = new Drawing();
         
      public Halloween()
      {
      // these are the picture files being used as well as the audioclips
         images[0] = new ImageIcon("C:\\comp sci\\eclipse java prog\\New Halloween OOP\\src\\flyingwitch.jpg");
         images[1] = new ImageIcon("C:\\comp sci\\eclipse java prog\\New Halloween OOP\\src\\ghost.jpg");
         images[2] = new ImageIcon("C:\\comp sci\\eclipse java prog\\New Halloween OOP\\src\\jack-o-lantern.jpg");
         try{
            audioclip[0] =Applet.newAudioClip(new URL("C:\\comp sci\\eclipse java prog\\New Halloween OOP\\src\\mywitch.au"));
            audioclip[1] =Applet.newAudioClip(new URL("C:\\comp sci\\eclipse java prog\\New Halloween OOP\\src\\Lalala.au"));
          // audioclip[2] =getAudioClip(getCodeBase(),"PATCH.AU");
         } 
            catch (MalformedURLException murle){};
         jframe.add(draw);
         JPanel top = new JPanel();
         top.add(bwitch);
         bwitch.addActionListener(this);
         top.add(bghost);
         bghost.addActionListener(this);
         jframe.add(top, "North");
         jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          jframe.setSize(300,300);
          jframe.setVisible(true);
      }
      public void start()
      {
         (thread = new Thread (this)).start();
      }
      public void stop()
      {
         thread = null;
      }
      class Drawing extends JComponent
      {
         public void paint (Graphics g)
         {
            g.drawImage(images[frame].getImage(),50,50,300,300,this);
            audioclip[frame].play();
         // image and sound play as user mouse clicks on button
         
            button= 2;
         
         // button = 2 is default pumkin
         }
      }   
      public void actionPerformed(ActionEvent e)
      {
         if (e.getSource()==bwitch)
         {
            button= 0;
         }
         else if (e.getSource()==bghost)
         {
            button = 1;
         }
      }
   
      public void run()
      {
         int delay = 6000;
         try
         {
            while (thread==Thread.currentThread())
            {
            // changes screen into the picture that was chosen and then repaints the original screen
               frame = button;
               draw.repaint();
               Thread.sleep(delay);
            }
         }
            catch (Exception e)
            {
            }
      }//end of NewHalloween program
      public static void main(String [] args)
      {
         new Halloween();
      }
   }// Happy Halloween!!

Download Easter Egg Image and Sound files

Multimedia Threaded Easter Egg Demo


Download Threaded Easter Egg source

Multimedia Halloween Demo


Download Halloween source

Random Easter Eggs Demo


Download Random Easter Eggs source

Interactive GUI Demo



Interactive GUI Demo with File Handling



Interactive Theatre Reservation - parallel arrays



Precipitation - 2 D arrays


Java Multimedia Tutorial TOC




Applets VS Applications


Swing Library


Abstract Windows Toolkit - Sound, Images and GUI


Threads



OOP Multimedia Design Challenge



OOP Demo





My Favorite JSP resource and tutorial sites


WS_FTP PRO - essential CGI tool
JSP Resource Index - Java Server Pages site
JSP and Servlet tutorial
Servlet tutorial
Servlets.COM - home of the Beans

Make dynamic web pages using JSP.

Java Programming Sites


Java By Example
Dick Baldwin's Java Programming site
Intro to OOP - Don't Fear the OOP
JR's Education Pages - Java
Cornell U Computer Science on Java
Big Java - Horstmann
Daniweb - Java
Formatting Numbers



K-DOG Inc.


<%@ include file="date.jsp" %>


Choose:   K-DOG Home   I   Contact Us