I'm trying to create a burst on the screen by running through an image array. As a test I created 3 gif images named One, Two, and Three (each one displays the associated number). The problem is, there is no way to view each image in the array; the only image that is viewable by the human eye is the last one in the array (but each one is viewable if it is selected alone). Does anyone have any advice/links on a solution to this? Been googling this and can't find much help. My code is below.

burst = new BufferedImage[3];
                try
                {
                burst[0] = ImageIO.read(getClass().getResource("images\\one.gif"));
                burst[1] = ImageIO.read(getClass().getResource("images\\two.gif"));
                burst[2] = ImageIO.read(getClass().getResource("images\\three.gif"));
                //burst[3] = ImageIO.read(getClass().getResource(".gif"));
                //burst[4] = ImageIO.read(getClass().getResource(".gif"));
                //burst[5] = ImageIO.read(getClass().getResource(".gif"));
                //burst[6] = ImageIO.read(getClass().getResource(".gif"));
                //burst[7] = ImageIO.read(getClass().getResource(".gif"));
                //burst[8] = ImageIO.read(getClass().getResource(".gif"));
                //burst[9] = ImageIO.read(getClass().getResource(".gif"));
                }catch (Exception ex){System.out.println("Invalid Image");}

                for(int i = 0; i < burst.length; i ++)
                {
                    for(int t = 0; t < 100; t ++)
                    {
                        g2d.drawImage((BufferedImage)burst[i], 150, 150, null);
                    }
                }

One thing to add is that this is all for a JPanel, not an applet. With an applet I'd say a good SLEEP statement would be good, but that's not going to work here.

for(int i = 0; i < burst.length; i ++)
                {
                    for(int t = 0; t < 100; t ++)
                    {
                        g2d.drawImage((BufferedImage)burst[i], 150, 150, null);
                    }
                }

It looks to me like you are drawing all of the images at the same coordinates (150, 150), so wouldn't they all paint over each other and so you'd only see the last one? Also, why are you drawing each of them 100 times?

It looks to me like you are drawing all of the images at the same coordinates (150, 150), so wouldn't they all paint over each other and so you'd only see the last one? Also, why are you drawing each of them 100 times?

The whole objective to this part of the application is to illustrate an explosion. In theory, the array would have several images, each a different stage or level of the explosion's burst. The reason for the inner loop in my code segment was to attempt a delay so that each image in the array would be viewable instead of only the last. (am doing the explosion this way since the other way wasn't working too well).

So you are drawing images intentionally in the same space and intentionally drawing over them, and that is the goal, but is drawing too fast for the human eye to register? How about using the sleep command using threads to pause between images? So if there was a thread t and you wanted to pause for 250 milliseconds, you could do this:

t.sleep (250);

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#sleep(long)

So you are drawing images intentionally in the same space and intentionally drawing over them, and that is the goal, but is drawing too fast for the human eye to register? How about using the sleep command using threads to pause between images? So if there was a thread t and you wanted to pause for 250 milliseconds, you could do this:

t.sleep (250);

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#sleep(long)

Can I do that within a JPanel? If this was an applet that would be my first thought, but with this using JPanel instead of applet, didn't think that was an option.

Can I do that within a JPanel? If this was an applet that would be my first thought, but with this using JPanel instead of applet, didn't think that was an option.

I've done it with a JFrame. If it can be done with a JFrame, I imagine it could be done with a JPanel.

commented: Poster has good information and is helpful +1

I've done it with a JFrame. If it can be done with a JFrame, I imagine it could be done with a JPanel.

Good to know. I'll try that today and see what I get. Thanks.

No-go. I'll try doing this in another file in the program but it still just only shows the last image in the array. Been going nuts on this part of the code for the last two months now (trying a few different ways). All I want is to get the app to render some sort of explosion.

You should update the image, repaint, and sleep in a separate thread or a Swing Timer. This animation tutorial might help:http://www.developer.com/java/article.php/893471
The important concept is that the AWT Event Queue needs to be allowed to repaint after you have altered the image.

commented: Very helpful, has good information to contribute. +1

Here is what I had in mind with the Thread sleep. I tweaked a program I had and got this. It draws a circle, but I don't imagine it would be different from drawing an image of an explosion to the screen. It creates a JFrame and within that JFrame adds a class that extends JComponent. It continually draws different colored circles, pausing long enough so you can see each circle. You could change the circles to stages of an explosion.

// Filename : Explosion.java
package Explosion;


import java.awt.*;
import javax.swing.*;


public class Explosion
{
    public static void main(String[] args)
    {
        int initialWindowWidth  = 400;
        int initialWindowHeight = 400;
        JFrame frame = new JFrame ("Explosion");
        frame.add (new ExplosionComponent ());
        frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        frame.setSize (initialWindowWidth, initialWindowHeight);
        frame.setVisible (true);
    }
}


class ExplosionComponent extends JComponent implements Runnable
{
    int explodeVertPos  = 150;
    int explodeHorizPos = 150;
    int explodeDiameter = 50;
    Color[] colors = {Color.green, Color.blue, Color.red};
    int numColors = 3;
    int curColorIndex = 0;
    
    
    public ExplosionComponent ()
    {
        Thread t = new Thread (this);
        t.start ();      
    }
    

    public void paintComponent (Graphics g)
    {
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint (RenderingHints.KEY_ANTIALIASING, 
            RenderingHints.VALUE_ANTIALIAS_ON);

        g2.setPaint (colors[curColorIndex]);
        g2.fillOval (explodeHorizPos, explodeVertPos, explodeDiameter, 
            explodeDiameter);        
    }
    
    public void run ()
    {
         try
         {
            while (true)
            {
                if (curColorIndex == numColors - 1)
                    curColorIndex = 0;
                else
                    curColorIndex++;
                repaint ();
                Thread.sleep (300);
            }
        }
        catch (InterruptedException ie)
        {
        }
    }
}
commented: Clear example +6

Yes, good example. That's the general idea that I was referring to as well. Alterations to the data that is being rendered, whether it is positional info on primitives or BufferedImages, occurs in a separate thread or Timer component with calls to repaint(). The paint method itself just renders that data.

Thanks to both of you for the reply. Looking at both recommendations. I'll let you know if I have more questions.

OK, one problem with trying to implement run() within this file is due to a possible conflict (didn't realize till now). The Panel file extends another file that has a run() function; I'll paste them both below but basically the outter panel (named ABSFireworksPanel) controls rendering the game, starting/stopping the game, and anything related to the instance of the game. The inner panel file (named FireworksPanel) deals with the actions or details with the game itself (displaying score, rendering rockets, etc). I was trying to get the run() from ABSFireworksPanel to control the thread for the explosion, but it doesn't seem to work (as tested with a println statement). Is there any way to get the run() in the ABSFireworksPanel to work with the code in the FireworksPanel class? If not, what is the best alternative to this? In short, I'm not sure how to do a refresh the screen to show new images (repaint does entire screen)?? I've been trying several different things in order to generate an explosion, but the the only "burst" is a bomb of an attempt. Any recommendations to a FRUSTRATED coder?????

package Fireworks;

import java.awt.Color;
import java.awt.Font;
import java.awt.*;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.JPanel;
import java.util.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.net.*;
import javax.sound.midi.*;
import javax.sound.sampled.*;
import java.applet.AudioClip;

public abstract class AbsFireworksPanel extends JPanel implements Runnable   
{
    private Thread animation = null;
    private boolean running = false;
    volatile boolean gameOver = false;
    private Image dbImage; // = null;
    private Graphics2D dbg;
    Fireworks Game;
    
    
        int explodeVertPos  = 150;
    int explodeHorizPos = 150;
    int[] explodeDiameter = {5, 10, 15, 20, 25, 30, 50};
    //Color[] colors = {Color.green, Color.blue, Color.red, Color.yellow, Color.BLACK, Color.ORANGE, Color.CYAN};
    Color colors = Color.RED;
    
    int numColors = 7;
    int curColorIndex = 0;
    int numDiameter = 7;
    int curDiameter = 0;
    int curDiameterIndex = 0;
    
    
    protected double startTime, endTime;
    private long period = (1000/Constants.SPEED) * 1000000L;
    
    public AbsFireworksPanel() 
    {
        initComponents();
        startTime = System.nanoTime();
    }
    
    public void startGame()
    {
        if(animation == null)
        {
            animation = new Thread(this);
            animation.start();
            endTime = System.nanoTime();
        }
    }
    
    public void run(){
          
          long sleepTime;
                
          running = true;
          
          while(running){
            renderGame();
            updateGame();
            paintScreen();
            
            
            sleepTime = 100;
            
            if(sleepTime > 0)
            {
                
                try{
                    Thread.sleep(50);
                } catch(Exception exc){   
                }
                
            }

            }
            
                updateGame();                
          try
         {
            while (true)
            {
                if (curColorIndex == numColors - 1)
                    curColorIndex = 0;
                else
                    curColorIndex++;
                System.out.println("TEST EXPLODE!!");
                if(curDiameterIndex == numDiameter - 1)
                    curDiameterIndex = 0;
                else
                    curDiameterIndex ++;
                repaint ();
                Thread.sleep (500);
            }
        }
        catch (InterruptedException ie)
        {
        }
  
    }
    
   
    public void stopGame()
    {
        running = false;
    }
    
    public boolean getRunningStatus(){
          return running;
      }
    
    public void resumeGame()
    {
        running = true;
    }
    
    public void renderGame()
    {
        if(dbImage == null)
        {
            dbImage = createImage(Constants.WIDTH, Constants.HEIGHT);
            if(dbImage == null)
            {
                System.out.println("dbImage is null");
            }
            else
            {
                dbg = (Graphics2D)dbImage.getGraphics();
            }
        }
        
        //clear the background
        dbg.setColor(Color.BLACK);
        dbg.fillRect(0, 0, Constants.WIDTH, Constants.HEIGHT);
        
        //draw game elements
        renderSprites(dbg);
        
        if(gameOver)
        {
            endGame(dbg);
        }
    }
    
        public void endGame(Graphics2D g2d){
          if(getGameOver()){
              callEndGame(dbg);
              stopGame();
          }
      }
    
        public void paintScreen()
        {
            Graphics2D sg = (Graphics2D)this.getGraphics();
            if(dbImage != null)
            {
                sg.drawImage(dbImage, 0, 0, null);
            }
            sg.dispose();
        }
        
        public void setGameOver(boolean gameOver){
          this.gameOver = gameOver;
      }
      
      public boolean getGameOver(){
          return gameOver;
      }
        
        public abstract void updateGame();
        public abstract void callEndGame(Graphics2D g2d);
        public abstract void renderSprites(Graphics2D g2d);
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */


    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
    private void initComponents() {

        setLayout(new java.awt.BorderLayout());

    }// </editor-fold>                        
    
    
    // Variables declaration - do not modify                     
    // End of variables declaration                   

      
}
package Fireworks;

/*import java.awt.Graphics;
import java.awt.Graphics2D;*/
import java.awt.*;
/*import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;*/
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.imageio.ImageIO;
import java.util.*;
import java.applet.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
import javax.sound.midi.*;
import javax.sound.sampled.*;
import java.applet.AudioClip;
import javax.swing.JButton;


public class FireworksPanel extends AbsFireworksPanel //implements Runnable
{
    Fireworks Game;
    FireworksSprite aFirework;
    FireworksSprite[] fireworks;
    FireworksSpinnerSprite[] spinner;
    FireworksRocketSprite[] rocket;
    FireworksSprite oneExplosion;
    private FireworksSprite explosion[];
    private BufferedImage burst[];
    int GameScore;
    String type = null;
    String Explosion = "fireworks.wav";
    String bgSong = "WilliamTell.wav";
    SongSprite bgsong, bgnoise;
    Thread animation;
    Graphics2D dbg;
    SongSprite[] bgSound, explode;
    int[] rTime;
    int arTime;

    
    int explodeVertPos  = 150;
    int explodeHorizPos = 150;
    int[] explodeDiameter = {5, 10, 15, 20, 25, 30, 50};
    Color[] colors = {Color.green, Color.blue, Color.red, Color.yellow, Color.BLACK, Color.ORANGE, Color.CYAN};
    //Color colors = Color.RED;
    
    int numColors = 7;
    int curColorIndex = 0;
    int numDiameter = 7;
    int curDiameter = 0;
    int curDiameterIndex = 0;
    
    
    private int mx,my;
    
    int RocketX[], RocketY[];
  
    
    public FireworksPanel() 
    {
        //initComponents();
        GameScore = 0;
        setPreferredSize(new Dimension(Constants.WIDTH, Constants.HEIGHT));
        initRocket();
        initFireworks();
        Thread t = new Thread (this);
        t.start ();
         //callEndGame(dbg);
     //   soundeffects(bgSong);
     //   SoundTrack();
    }
    
        public void paint(Graphics g)
       {
           g.setColor(Color.black);
           g.fillRect(0,0,mx+500,my+500);
           //DisplayGameScore(GameScore, g);
        }

    
    public void setGame(Fireworks Game)
    {
        this.Game = Game;
    }
    
        
    public Fireworks getGame()
    {
        return Game;
    }
    
    
    public void initRocket()
    {
        aFirework = new FireworksSprite();
        aFirework.setActive(false);
        aFirework.setVisible(false);
        aFirework.addPropertyChangeListener(new FireworksSpriteArrayChangeListener());
    }
    
    
    public void initFireworks()
    {
        fireworks = new FireworksSprite[Constants.FIREWORKS_COUNT];
        spinner = new FireworksSpinnerSprite[Constants.SPINNER_COUNT];
        rocket = new FireworksRocketSprite[Constants.ROCKET_COUNT];
        rTime = new int[Constants.FIREWORKS_COUNT];
        for (int i = 0; i < Constants.FIREWORKS_COUNT; i ++)
        {
            fireworks[i] = new FireworksSprite();
            fireworks[i].setActive(false);
            fireworks[i].setVisible(false);
            fireworks[i].addPropertyChangeListener(new FireworksSpriteArrayChangeListener());
	}

        for (int i = 0; i < Constants.SPINNER_COUNT; i ++)
        {
            spinner[i] = new FireworksSpinnerSprite();
            spinner[i].setActive(false);
            spinner[i].setVisible(false);
            spinner[i].addPropertyChangeListener(new FireworksSpriteArrayChangeListener());
        }
        
        for (int i = 0; i < Constants.ROCKET_COUNT; i ++)
        {
            rocket[i] = new FireworksRocketSprite();
            rocket[i].setActive(false);
            rocket[i].setVisible(false);
            rocket[i].addPropertyChangeListener(new FireworksSpriteArrayChangeListener());
        }
        
        
        /*for(int i = 0; i < Fireworks.length; i ++)
        {
            Fireworks[i].paintSprite(g2d);
        }
        
        for(int i=0; i < totalBurst; i++)
      {
        //vx[i]=(int)(Math.random()*power)-power/2;
        //vy[i]=(int)(Math.random()*power*7/8)-power/8;
      }*/
        
        //renderSprites(dbg);
        //soundeffects(Explosion);
    }
    
    
    public void renderSprites(Graphics2D g2d)
    {
        DisplayGameScore(GameScore, g2d);
        aFirework.paintSprite(g2d);
        for (int i = 0; i < fireworks.length; i ++)
        {
            fireworks[i].paintSprite(g2d);
            if(aFirework.getLocy()<35 && aFirework.getLocy()> 0)
            {
       /*         int initialWindowWidth  = 400;
                int initialWindowHeight = 400;
                JFrame frame = new JFrame ("Explosion");
                frame.add (new ExplosionComponent ());
                frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
                frame.setSize (initialWindowWidth, initialWindowHeight);
                frame.setVisible (true);
*/
                paintExplosion(g2d);  //initBurst(g2d);
            }
        }
        
        for (int i = 0; i < spinner.length; i ++)
        {
            spinner[i].paintSprite(g2d);
        }   
        
        for (int i = 0; i < rocket.length; i ++)
        {
            rocket[i].paintSprite(g2d);
        }
        
        
        FireworksShow();
     
        
        //renderRocket();
        //g2d.setFont(new Font("TimesRoman", Font.BOLD,20));
        /*g2d.setColor(Color.WHITE);
        g2d.drawString("Fireworks Display", Constants.WIDTH/2, Constants.HEIGHT/2);
        //renderSprites(g2d);
        SoundEffect();*/
    }
    
    public void paintExplosion(Graphics2D g2d)
    {
        for(int i = 0; i < 7; i ++)
        {
        //Graphics2D g2 = (Graphics2D) g;
        g2d.setRenderingHint (RenderingHints.KEY_ANTIALIASING, 
            RenderingHints.VALUE_ANTIALIAS_ON);

        g2d.setPaint (colors[curColorIndex]);
        g2d.fillOval (explodeHorizPos, explodeVertPos, explodeDiameter[curDiameterIndex], explodeDiameter[curDiameterIndex]); 
        repaint();
        }
    }
   
     private void DisplayTestMsg(Graphics2D dbg)
     { 
        dbg.setFont(new Font("Times New Roman", Font.BOLD, 30));
        dbg.setColor(Color.YELLOW);
        dbg.drawString("Test Message ", 150, 150);
    }
    
    public void FireworksShow()
    {
        addKeyListener(new KeyAdapter()
        {
            public void keyPressed(KeyEvent event)
            {
                switch(event.getKeyCode())
                {
                    case KeyEvent.VK_LEFT:
                    {
                        //Launch firework type 1.
                        for(int i = 0; i < fireworks.length; i++)
                        {
                            if(aFirework.getLocy() < 15)
                            {
                                GameScore = GameScore + 5;
                            }
                           if(!fireworks[i].isLaunched() && !fireworks[i].isVisible())
                            {
                                arTime = 0;
                                fireworks[i].setLaunchTime(System.nanoTime());
                                renderRocket("firework");
                            }

                            else
                            {
                                fireworks[i].setExplodeTime(System.nanoTime());
                                int tTime = (int)Math.round(((((fireworks[i].getExplodeTime() - fireworks[i].getLaunchTime())/1000000000)*100) % 1000000)/100.0);
                                if(tTime >= arTime)
                                {
                                    fireworks[i].setVisible(false);
                                    fireworks[i].setLaunched(false);
                                }
                            }
                         }
                       }
                        break;
                        
                        case KeyEvent.VK_UP:
                    {
                        //Launch firework type 2.
                       for(int i = 0; i < spinner.length; i++)
                      {
                           if(aFirework.getLocy() < 15)
                            {
                                GameScore = GameScore + 5;
                            }
                           if(aFirework.getLocy() < 15)
                            {
                                GameScore = GameScore + 5;
                            }
                           if(!spinner[i].isLaunched() && !spinner[i].isVisible())
                                {
                                    arTime = 0;
                                    spinner[i].setLaunchTime(System.nanoTime());
                                    renderRocket("spinner");
                                }

                            else
                            {
                                spinner[i].setExplodeTime(System.nanoTime());
                                int tTime = (int)Math.round(((((spinner[i].getExplodeTime() - spinner[i].getLaunchTime())/1000000000)*100) % 1000000)/100.0);
                                if(tTime >= arTime)
                                {
                                    spinner[i].setVisible(false);
                                    spinner[i].setLaunched(false);
                                }
                            }
                          }
                        }
                        break;
                        
                        case KeyEvent.VK_RIGHT:
                    {
                        //Launch firework type 3.
                        for(int i = 0; i < rocket.length; i++)
                        {
                            if(aFirework.getLocy() < 15)
                            {
                                GameScore = GameScore + 5;
                            }
                            if(!rocket[i].isLaunched() && !rocket[i].isVisible())
                                {
                                    arTime = 0;
                                    rocket[i].setLaunchTime(System.nanoTime());
                                    renderRocket("rocket");
                                }

                            else
                            {
                                rocket[i].setExplodeTime(System.nanoTime());
                                int tTime = (int)Math.round(((((rocket[i].getExplodeTime() - rocket[i].getLaunchTime())/1000000000)*100) % 1000000)/100.0);
                                if(tTime >= arTime)
                                {
                                    rocket[i].setVisible(false);
                                    rocket[i].setLaunched(false);
                                }
                            }
                          }
                        break;
                      }
                    }
                  }
             });
     }

    //public void run ()
    //{
         /*try
         {
            while (true)
            {
                if(curColorIndex == numColors - 1)
                    curColorIndex = 0;
                else
                    curColorIndex++;
                
                if(curDiameterIndex == numDiameter - 1)
                    curDiameterIndex = 0;
                else
                    curDiameterIndex ++;
                repaint ();
                Thread.sleep (300);
            }
        }
        catch (InterruptedException ie)
        {
        }*/
    //}
    
    public void initBurst(Graphics2D g2d)
    {
        
        burst = new BufferedImage[3];
        try
        {
        burst[0] = ImageIO.read(getClass().getResource("images\\one.gif"));
        burst[1] = ImageIO.read(getClass().getResource("images\\two.gif"));
        burst[2] = ImageIO.read(getClass().getResource("images\\three.gif"));
        //burst[3] = ImageIO.read(getClass().getResource(".gif"));
        //burst[4] = ImageIO.read(getClass().getResource(".gif"));
        //burst[5] = ImageIO.read(getClass().getResource(".gif"));
        //burst[6] = ImageIO.read(getClass().getResource(".gif"));
        //burst[7] = ImageIO.read(getClass().getResource(".gif"));
        //burst[8] = ImageIO.read(getClass().getResource(".gif"));
        //burst[9] = ImageIO.read(getClass().getResource(".gif"));
        }catch (Exception ex){System.out.println("Invalid Image");}

        //for(int i = 0; i < burst.length; i ++)
        //{
            //for(int t = 0; t < 100; t ++)
            //{
                
                try 
                {
                   g2d.drawImage((BufferedImage)burst[0], 150, 150, null);
                   animation.sleep(100);
                   g2d.drawImage((BufferedImage)burst[1], 150, 150, null);
                }
                catch(InterruptedException x){}

                    
               
                //load the explosion
                /*explosion = new AnimationSprite(this, g2d);
                explosion.load("explosion96x96x16.png", 4, 4, 96, 96);
                explosion.setFrameDelay(2);
                explosion.setAlive(false);*/
               //startExplosion   //this.getLocx(), this.getLocy(), g);
               //drawExplosions
           /*int gravity, a, v, T, L, x, y;
           explosion = new FireworksSprite[100];
           oneExplosion = new FireworksSprite();
           double valueA, valueB, dx, dy;
           int t = 0;
           Random r = new Random();
           for(t = 0; t < explosion.length; t ++)
          {
               gravity = 20;
               a = 15; //r.nextInt(5);
               v = 10; //r.nextInt(5);
               //System.out.println("a = " + a);
               //System.out.println("v = " + v);
               valueA = v*Math.sin(a)*t;
               valueB = (.5)*gravity*(t*t);
               dx = (int)v*Math.cos(a)*t;
               dy = (int)valueA - valueB;
               x = (int)dx;
               y = (int)dy;
               oneExplosion = new FireworksSprite();
               oneExplosion.setSpriteH(15);
               oneExplosion.setSpriteW(10);
               oneExplosion.setLocx(x);
               oneExplosion.setLocy(y);
               oneExplosion.setActive(true);
               oneExplosion.setVisible(true);
               oneExplosion.setVel(0, v); 
               //System.out.print("Iterating through Array" + t);
               /*explosion[t] = new FireworksSprite();
               explosion[t].setSpriteH(15);
               explosion[t].setSpriteW(10);
               explosion[t].setLocx(x);
               explosion[t].setLocy(y);
               explosion[t].setActive(true);
               explosion[t].setVisible(true);
               explosion[t].setVel(0, v);*/ 
              /* for (int i = 0; i < explosion.length; i ++)
               {
                  g2d.setColor(Color.YELLOW);
                  g2d.fillOval(x, y, 25, 25);
                  //g2d.drawLine(x, y, x+50, y+50);
               }
           }*/
        //}
    }
    
    public void renderRocket(String type)
    {
        if(type == "firework")
        {
            aFirework.setSpriteH(15);
            aFirework.setSpriteW(5);
            aFirework.setLocx(250);
            aFirework.setLocy(600);
            aFirework.setActive(true);
            aFirework.setVisible(true);
            aFirework.setLaunched(true);
            aFirework.setVel(3, -15);
        }
        
        if(type == "spinner")
        {
            aFirework.setSpriteH(15);
            aFirework.setSpriteW(5);
            aFirework.setLocx(250);
            aFirework.setLocy(600);
            aFirework.setActive(true);
            aFirework.setVisible(true);
            aFirework.setLaunched(true);
            aFirework.setVel(-3, -15);
        }
        
        if(type == "rocket")
        {
            aFirework.setSpriteH(15);
            aFirework.setSpriteW(5);
            aFirework.setLocx(250);
            aFirework.setLocy(600);
            aFirework.setActive(true);
            aFirework.setVisible(true);
            aFirework.setLaunched(true);
            aFirework.setVel(10, -15);
        }
    }
    
    
     public void updateGame()
     {
         aFirework.updateSprite();
         for(int n = 0; n < fireworks.length; n ++)
         {
             fireworks[n].updateSprite();
         }
         
         for(int t = 0; t < spinner.length; t ++)
         {
             spinner[t].updateSprite();
         }
         
         for(int l = 0; l < rocket.length; l ++)
         {
             rocket[l].updateSprite();
         }
         
     }
    
      
    public void callEndGame(Graphics2D dbg)
        {
           // if(gameOver)
            //{
                Font font = new Font("Times Roman", Font.BOLD, 50);
                dbg.setFont(font);
                dbg.setColor(Color.WHITE);
                String GameMsg = "Game Over";
                dbg.drawString(GameMsg, 150, 150);
                dbg.setFont(new Font("Times New Roman", Font.BOLD, 50));
                
                dbg.setColor(Color.YELLOW);
                dbg.drawString("Fireworks Display", 100, 100);
                dbg.drawString("Final Score:", 200, 200);
                dbg.setFont(new Font("Times New Roman", Font.BOLD, 15));
                dbg.drawString("Fireworks Display Program.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 40);
                dbg.drawString("Final Project, CS8680, Dr. Xu, KSU MSACS", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 60);
                dbg.drawString("Nathan Williams", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 80);
                dbg.drawString("Fall 2007.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 100);   
            //}
        }
    
    
    class LocChangeListener implements PropertyChangeListener{
        public void propertyChange(PropertyChangeEvent evt){
            
            if((evt.getPropertyName()).equals("NewP")){
               Point newL  = (Point)evt.getNewValue();
               
               Rectangle rocket = new Rectangle((int)newL.getX(),(int)newL.getY() + aFirework.getSpriteH()/2, aFirework.getSpriteW(),aFirework.getSpriteH());
            }             
        }
    }   
    
    
class FireworksSpriteArrayChangeListener implements PropertyChangeListener
{
        public void propertyChange(PropertyChangeEvent evt)
        {
           
            if((evt.getPropertyName ()).equals("NewP")){
               Point newL  = (Point)evt.getNewValue();
               //Oval fireworks = new Oval((int)newL.getX(),(int)newL.getY(), fireworks.getSpriteW(), fireworks.getSpriteH()/2);              
               Rectangle rocket = new Rectangle((int)newL.getX(),(int)newL.getY() + aFirework.getSpriteH()/2, aFirework.getSpriteW(),aFirework.getSpriteH());               
            } 
          
        }

        
    }
    

     public void SoundTrack()
    {
      //Initialize background music.
        bgsong = new SongSprite();
        bgsong.setFilename(Constants.SONG);
        //bgSound[0] = bgsong;
        System.out.println("Now Playing Song");
        //bgsong.loadClip();
        bgsong.play();
    }

     
     public void soundeffects(String filename)
    {
        //Initialize audio sound effects.
       
            //for (int i = 0; i < Fireworks.length; i++)
            //{
                try
                {
                AudioClip FireworkSound = Applet.newAudioClip(getClass().getResource(filename));
                FireworkSound.play();
                }
                catch(Exception e)
                {
                    System.out.println("Problem with " + filename);
                }
            //}
            
           // AudioClip FireworkSong = Applet.newAudioClip(getClass().getResource(filename));
           // FireworkSong.play();
     }
    
     
    public void SoundEffect()
    {
        bgnoise = new SongSprite();
        bgnoise.setFilename(Constants.BANG);
        System.out.println("Now Playing Sound");
        
        bgnoise.play();  
    }

     
     private void DisplayGameScore(int theGameScore, Graphics2D dbg)
     { 
       // dbg = (Graphics2D)g;
        dbg.setFont(new Font("Times New Roman", Font.BOLD, 30));
        dbg.setColor(Color.YELLOW);
        dbg.drawString("Current Score is: " + theGameScore, 150,30);
    }
     
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
    private void initComponents() {

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>                        
    
    
    // Variables declaration - do not modify                     
    // End of variables declaration                   

}

Well I don't think I can run your program since it looks like it has at least one external .wav file. So let me see if I understand correctly. You have implemented a "println" command within the "run" function of the "AbsFireworksPanel" class, correct? You say that this DOES NOT work? You are attempting to display a line to the console, then sleep for half a second, then display the println again, etc. But it is not pausing between displays to the console screen? It is not displaying to the console screen at all? If you can get it to pause between console display messages, then Sleep is working, it would seem. If you can get that pause, you can call the paintComponent function of whichever class is painting the explosion, which I am guessing is the FireworksPanel class. I think if I was designing it, I would have one "run" function and that "run" function would be in the "AbsFireworksPanel". I would call the paintComponent of the "FireworksPanel" class from there (I believe the FireworksPanel class paints the explosion?). So, since I can't run it from here (I don't think), please let us know more specifically what the println command is doing, if anything. But it seems to me that if that can get working, the explosion should be doable too.

Also, I am not really that familiar with the "abstract" qualifier and whether that would affect anything. I notice you made AbsFireworksPanel abstract.

I don't really see where you are gaining anything by having AbsFireworksPanel be an abstract base implementation and FireworksPanel extending it - except perhaps headaches and confusion at this point. Why not combine those until you get it working as you would like and then, if there really is a reason to abstract some shared functionality out, refactor that as appropriate? If the only concrete implementation of AbsFireworksPanel that you have is FireworksPanel, you're just making one class be two for the sake of it.

Also, I am not really that familiar with the "abstract" qualifier and whether that would affect anything. I notice you made AbsFireworksPanel abstract.

In C++ it would be an abstract base class that declares pure virtual functions. Declaring the class abstract ensures that it cannot be instantiated itself and only serves as a base class for concrete subclasses. A better explanation can be found here: http://www.codeguru.com/java/tij/tij0079.shtml

I don't really see where you are gaining anything by having AbsFireworksPanel be an abstract base implementation and FireworksPanel extending it - except perhaps headaches and confusion at this point. Why not combine those until you get it working as you would like and then, if there really is a reason to abstract some shared functionality out, refactor that as appropriate? If the only concrete implementation of AbsFireworksPanel that you have is FireworksPanel, you're just making one class be two for the sake of it.

As I tried to say before, the two panel classes handle two seperate aspects of the application: the first one handles aspects dealing with the game itself, such as starting the game, stopping the game, etc. The other Panel class deals with the internal workings of the game, such as rendering the objects of the game, creating/instantiating the objects, etc. Let me know if you want to run the appl and I'll post the other supporting files and classes. The wav file is minor.
As for getting the outer panel class's run file to control everything, that's what I've been trying this week, but to no success. That was the reason for the println statement, to see if that specific code segment was being reached (it isn't). If you see anything I'm missing, PLEASE let me know as this explosion part has been a pain for the last 2 months!

Well, for us to get a feel for it we probably need the other classes (i.e. Fireworks, FireworksSprite, FireworksSpinnerSprite, etc.). Otherwise it won't compile, so it's harder to test out, so posting those classes could be helpful.

I do see one thing without running it. I don't know if this is a problem or not, but within your "run" function you have this while loop (I changed the brackets presentation to make it easier to see):

while(running)
{
            renderGame();
            updateGame();
            paintScreen();
                        
            sleepTime = 100;
            
            if(sleepTime > 0)
            { 
                 try
                 {
                    Thread.sleep(50);
                 } 
                 catch(Exception exc)
                 {   
                 }  
            }
}

Not sure when "running" is set false, but you will never get to your println statement while running is true as far as I can tell because you'll never get out of this while loop. So if the println statement is supposed to execute within this while loop, I think you may have a bracket problem.

Below are a few more of the files associated with this application. To save space I didn't add Constants, FireworksSpinnerSprite, and FireworksRocketSprite. The instances for the latter two can be replaced with FireworskSprite, and any value referring to Constants can be made up. Let me know if you have question, chances are I'll still be online.

By the way, if you see a log of code blocks in comments /* */ don't be confused or suprised. I have made several attempts at this, and for safe keeping have relocated those same attempts to lower in the screen in case I wished to revisit.


Fireworks.java
main file that executes entire app

package Fireworks;

import java.awt.*;
import java.util.*;
import java.applet.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
import javax.sound.midi.*;
import javax.sound.sampled.*;
import java.applet.AudioClip;
import java.awt.Container;
import java.awt.Graphics2D;
import java.awt.Image;
import java.lang.*;

public class Fireworks extends javax.swing.JApplet
  //public class Fireworks extends javax.swing.JFrame
{
    Container gameContainer;
    FireworksPanel fwPanel;
    InstructionsPanel fwGuide;
    FireworksDisplay fwDisplay;
    
    
    public Fireworks()
    {
        //initComponents();
        makeUI();
        setSize(Constants.WIDTH, Constants.HEIGHT);
        setVisible(true);
    }
    
    public void makeUI()
    {
        fwDisplay = new FireworksDisplay();
        fwGuide = new InstructionsPanel();
        fwDisplay.setGame(this);
        fwGuide.setGame(this);
        
        GameDisplay();
        add(fwDisplay);
        add(fwGuide);
    }
    
     public void GameDisplay()
    {
        fwDisplay.setEnabled(true);
        fwDisplay.setVisible(true);
              
        fwGuide.setEnabled(false);
        fwGuide.setVisible(false);
    }
    
    public void StartGame()
    {
        fwPanel = new FireworksPanel();
        fwPanel.setGame(this);
        fwPanel.setFocusable(true);   
        fwPanel.setEnabled(true);
        fwPanel.setVisible(true);
        
        add(fwPanel);
        fwDisplay.setEnabled(false);
        fwDisplay.setVisible(false);
        
        fwPanel.startGame();
       // init();
        
        /*JFrame frame = new JFrame ("Explosion");
        frame.add (new ExplosionComponent ());
        frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        frame.setSize (400, 400);
        frame.setVisible (true);*/
    }
    
    public void GuideDisplay()
    {
        fwGuide.setEnabled(true);
        fwGuide.setVisible(true);
        
        fwDisplay.setEnabled(false);
        fwDisplay.setVisible(false);
    }
    
    public void Back()
    {
        fwDisplay.setVisible(true);
        fwDisplay.setEnabled(true);
        
        fwGuide.setVisible(false);
        fwGuide.setEnabled(false);
    }
    
    /*
    public void init() 
    {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() 
            {
                public void run() {
                    initComponents();
                }
            });
        } catch (Exception ex) 
        {
            ex.printStackTrace();
        }
    }
    */
    
    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
                );
        layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
                );
    }
    // </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
  
    /*public static void main(String args[])
    {
        java.awt.EventQueue.invokeLater(new Runnable(){
            public void run()
            {
                new Fireworks().setVisible(true);
            }
        });
    }*/
}

FireworksDisplay
shows opening window

package Fireworks;

import java.awt.*;



public class FireworksDisplay extends javax.swing.JPanel 
{
    Fireworks Game;
    //int width, height;
    
    public FireworksDisplay() 
    {
        initComponents();
        setSize(Constants.WIDTH, Constants.HEIGHT);
        //width = Constants.WIDTH;
        //height = Constants.HEIGHT;
        repaint();
    }
    
    public void setGame(Fireworks Game)
    {
        this.Game = Game;
    }
    
    public Fireworks getGame()
    {
        return Game;
    }
    
    public void paintComponents(Graphics g)
    {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D)g;
        g2d.setFont(new Font("Times New Roman", Font.BOLD, 50));
        g2d.setColor(Color.BLUE);
        g2d.drawString("Fireworks Display", Constants.WIDTH/2, Constants.HEIGHT/2);
        g2d.setFont(new Font("Times New Roman", Font.BOLD, 15));
        g2d.drawString("Fireworks Display Program.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 40);
        g2d.drawString("Final Project, CS8680, Dr. Xu, KSU MSACS", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 60);
        g2d.drawString("Nathan Williams", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 80);
        g2d.drawString("Fall 2007.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 100);        
    }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setLayout(null);

        jButton1.setLabel("Start Game");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        add(jButton1);
        jButton1.setBounds(220, 170, 110, 23);

        jButton2.setText("Instructions");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        add(jButton2);
        jButton2.setBounds(220, 200, 110, 23);

    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        Game.GuideDisplay();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        Game.StartGame();
    }//GEN-LAST:event_jButton1ActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    // End of variables declaration//GEN-END:variables
    
}

Fireworksmove
handles movement for fireworks object

package Fireworks;


public class FireworksMove implements Moveable
{
    private int currX, currY;
    private int nextVx, nextVy;
    private int nextX, nextY;

    public FireworksMove() 
    {
    }
    
    public void calcVelocity()
    {
    }
    
    public void setCurrX(int x)
    {
        this.currX = x;
    }
    
    public int getCurrX()
    {
        return this.currX;
    }
    
     public void setCurrY(int y)
    {
        this.currY = y;
    }
    
    public int getCurrY()
    {
        return this.currY;
    }
    
    public void setNextVx(int vx)
    {
        this.nextVx = vx;
    }
    
    public void setNextVy(int vy)
    {
        this.nextVy = vy;
    }
    
    public int getNextVx()
    {
        return this.nextVx;
    }
    
    public int getNextVy()
    {
        return this.nextVy;
    }
    
    public int getNextX()
    {
        return this.nextX;
    }
    
    public void setNextX(int nextX)
    {
        this.nextX = nextX;
    }
    
     public int getNextY()
    {
        return this.nextY;
    }
    
    public void setNextY(int y)
    {
        this.nextY = y;
    }
    
    public void setPosition(int x, int y)
    {
        this.setCurrX(x);
        this.setCurrY(y);
    }
    
    public void setVelocity(int vx, int vy)
    {
        this.setNextVx(vx);
        this.setNextVy(vy);
    }
    
    public void updatePosition()
    {
        this.setNextX(getCurrX() + getNextVx());
        this.setNextY(getCurrY() + getNextVy());
    }
}

FireworksSprite

package Fireworks;

import java.awt.*;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.Point;
import java.util.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.lang.Thread;
import java.lang.Math;
import java.lang.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class FireworksSprite extends Sprite2D implements Runnable
{
	FireworksMove fwm;
	PropertyChangeSupport propChange;
	boolean launched;
	private long LaunchTime;
	private long ExplodeTime;
        double seed;
        int[] vx, vy;
	public int PosX, PosY;
	int dx, dy, x, y;
     //   AnimationSprite explosion;
        Thread thread;
	//private FireworksExplosionSprite bomb_Burst[];
     private FireworksSprite explosion[];
     private FireworksSprite oneExplosion;
        private BufferedImage burst[];
	int gravity = 20;
        int time = 0;
	int RocketX[], RocketY[];
        int burstCount = 90;
	int length = 150;
	Random random;
	public FireworksSprite()
	{
            super();
            propChange = new PropertyChangeSupport(this);
            fwm = new FireworksMove();
            LaunchTime = 0;
            ExplodeTime = 10;
            fwm.setVelocity(1,-5);
            launched = false;
	}
        
        
	public void setFireworksVelocity(int x, int y)
	{
		fwm.setVelocity(x, y);
	}
        
        public void run()
        {
        }
        
	public void paintSprite(Graphics2D g2d)
    {
       	if(isVisible())
        {
           Random r = new Random();
           Color color = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
           g2d.setColor(color);
           g2d.fillOval(this.getLocx(), this.getLocy(), 5, 5); 
           // call explosion once firework reaches alt of 15.
           if(this.getLocy()<=50 && this.getLocy()<=15)
           {
               //public void initBurst(Graphics2D g)
	//{
               
               
               /* burst = new BufferedImage[3];
                try
                {
                burst[0] = ImageIO.read(getClass().getResource("images\\one.gif"));
                burst[1] = ImageIO.read(getClass().getResource("images\\two.gif"));
                burst[2] = ImageIO.read(getClass().getResource("images\\three.gif"));
                //burst[3] = ImageIO.read(getClass().getResource(".gif"));
                //burst[4] = ImageIO.read(getClass().getResource(".gif"));
                //burst[5] = ImageIO.read(getClass().getResource(".gif"));
                //burst[6] = ImageIO.read(getClass().getResource(".gif"));
                //burst[7] = ImageIO.read(getClass().getResource(".gif"));
                //burst[8] = ImageIO.read(getClass().getResource(".gif"));
                //burst[9] = ImageIO.read(getClass().getResource(".gif"));
                }catch (Exception ex){System.out.println("Invalid Image");}

                for(int i = 0; i < burst.length; i ++)
                {
                    //for(int t = 0; t < 100; t ++)
                    //{
                        g2d.drawImage((BufferedImage)burst[i], 150, 150, null);
                        try 
                        {
                           thread.sleep(100);
                        }
                        catch(InterruptedException x){}

                    //}
                }
               */
                //load the explosion
                /*explosion = new AnimationSprite(this, g2d);
                explosion.load("explosion96x96x16.png", 4, 4, 96, 96);
                explosion.setFrameDelay(2);
                explosion.setAlive(false);*/
               //startExplosion   //this.getLocx(), this.getLocy(), g);
               //drawExplosions
           }
        }
    }
        
        public void initExplosion()
        {
            
        }
        
	public void updateSprite()
	{
            if(isVisible())
            {
                fwm.setVelocity(fwm.getNextVx(), fwm.getNextVy());
                fwm.setPosition(this.getLocx(), this.getLocy());
                fwm.updatePosition();
                this.setLocx(fwm.getNextX());
                this.setLocy(fwm.getNextY());
                rocketDecay();
                fireNewLocation(new Point(this.getLocx(), this.getLocy()));
            }
	}
    
        

	public void fireNewLocation(Point p)
	{
		Point oldLoc = new Point(0,0);

		Point newLoc = p;
		propChange.firePropertyChange("NewP",oldLoc,newLoc);
	}

	private void rocketDecay()
	{
		if(this.getLocy() <= 0 || this.getLocy() > 1000)
		{   //firework no longer visible
			this.setActive(false);
			this.setVisible(false);
		}

			//initBurst(PosX, PosY);            
	}

	public void addPropertyChangeListener(PropertyChangeListener listener)
	{
		propChange.addPropertyChangeListener(listener);
	}

	public long getLaunchTime()
	{
		return this.LaunchTime;
	}

	public boolean isLaunched()
	{
		return this.launched;
	}

	public void setLaunched(boolean bool)
	{
		this.launched = bool;
	}

	public void setLaunchTime(long LaunchTime)
	{
		this.LaunchTime = LaunchTime;
	}

	public long getExplodeTime()
	{
		return this.ExplodeTime;
	}

	public void setExplodeTime(long ExplodeTime)
	{
		this.ExplodeTime = ExplodeTime;
	}

	public void setVel(int x, int y)
	{
		fwm.setVelocity(x, y);
	}
}






               /*a = r.nextInt(50);  //(int)Math.random();
               v = r.nextInt(50);  //(int)Math.random();
               System.out.println("a = " + a);
               System.out.println("v = " + v);
               valueA = v*Math.sin(a)*t;
               valueB = (.5)*gravity*(t*t);
               dx = v*Math.cos(a)*t;
               dy = valueA - valueB;       //v*Math.sin(a)*t-.5gravity*t*t;
           System.out.println("dx = " + dx);
           System.out.println("dy = " + dy);*/




/*
class FireworksExplosionSprite
{
   public int powerLevel;
   public int burstCount;
   public int length_of_stream;
   public int gravity;
   public int time;
   public int[] vx, vy;
   public int  x, y;
   public double seed;
   Color color;
   public boolean sleep = true;
   private int dx, dy;
   private Random random;
   
   public FireworksExplosionSprite(int xSprite, int ySprite, int g)
   {
       dx = xSprite;
       dy = ySprite;
       gravity = g;
   }
   
   public void initExplosion(int power, int burst, int length, Color burstColor, long seed)
   {
       powerLevel = power;
       burstCount = burst;
       length_of_stream = length;
       color = burstColor;
       random = new Random(seed);
       vx = new int[burstCount];
       vy = new int[burstCount];

       for(int i = 0; i < burstCount; i ++)
       {
             vx[i] = (int)(Math.random()*powerLevel)-powerLevel/2;
             vy[i] = (int)(Math.random()*powerLevel*7/8)-powerLevel/8;
       }
   }
   
   public void start()
   {
        time = 0;
        sleep = false;
   }

*/	
	/*public void setExplosionSpeed(int burstSpeed)
	{
	}

	public int getExplosionSpeed(int burstSpeed)
	{
		return burstSpeed;
	}

	public void setExplosionStyle(int burstSpeed)
	{
	}

	public int getExplosionStyle(int burstSpeed)
	{
		return burstSpeed;
	}

	public void setBurstEnergy(int burstSpeed)
	{
	}

	public int getBurstEnergy(int burstSpeed)
	{
		return burstSpeed;
	}

	public void setRocketNumber(int burstSpeed)
	{
	}

	public int getRocketNumber(int burstSpeed)
	{
		return burstSpeed;
	}

	public void setBurstCount(int burstSpeed)
	{
	}

	public int getBurstCount(int burstSpeed)
	{
		return burstSpeed;
	}

	public void setRocketTailLength(int burstSpeed)
	{
	}

	public int getRocketTailLength(int burstSpeed)
	{
		return burstSpeed;
	}

	public void setGravityStrength(int burstSpeed)
	{
	}

	public int getGravityStrength(int burstSpeed)
	{
		return burstSpeed;
	}*/
	
   
  /* public void paint(Graphics g)
   {
       if(!sleep)
       {
	   if(time < length_of_stream)
	   {
               double s;
		   for(int i = 0; i < burstCount; i ++)
		   {
                       s = (double)time/100;
                       x = (int)(vx[i]*s);
                       y = (int)(vy[i]*s-gravity*s*s);
                       g.setColor(Color.YELLOW); //color);
                       g.drawLine(dx + x, dy - y, dx + x, dy - y);
                       if(time >= length_of_stream/2)
                       {
                               for(int k = 0; k < burstCount; k ++)
                               {
                                       s = (double)((time-length_of_stream/2)*2+k)/100;
                                       x = (int)(vx[i]*s);
                                       y = (int)(vy[i]*s-gravity*s*s);
                                       g.setColor(Color.BLACK);
                                       g.drawLine(dx + x, dy - y, dx + x, dy - y);
                               }
                       }
                   }

		   time ++;
                }
               else
               {
                   sleep = true;
               }
           }
       }*/
   //}




/*             int i;
           int e = 200;
           int p = 100;
           int l = 100;
           long s = (long)(Math.random()*10000);
           boolean sleep;
//Graphics g = getGraphics();
           while(true)
              {
                try 
              {
                 animation.sleep(20);
              }
              catch(InterruptedException x){}

              sleep=true;
              for(i=0;i<MaxRocketNumber;i++)
                 sleep=sleep&&bomb_Burst[i].sleep;
              if(sleep&&Math.random()*100<RocketStyleVariability)
                 {
                   e=200;
                   p=100;
                   l=100;
                   s=(long)(Math.random()*10000);
                 }
    //         }
           
              for(i=0;i<MaxRocketNumber;i++)
                 {
                 if(bomb_Burst[i].sleep&&Math.random()*MaxRocketNumber*l<1)
                    {

                    bomb_Burst[i].initExplosion(e,p,l,Color.YELLOW,s);
                    bomb_Burst[i].start();
                    }
                 bomb_Burst[i].paint(g);
                 }
              }
*/



/*int AnimationSpeed = 100;
       int RocketValue = 20;
       int RocketCount = 10;
       int RocketPower = 500;
       int RocketBurstCount = 50;
       int RocketBurstLength = 100;
       int time = 0;
       int power, burst, length;
       int dx, dy;
       int RocketX[], RocketY[];
       int Gravity = 20;
       Random random;
       //mx=350;
       //my=200;

       power =(int)(Math.random()*RocketPower*3/4) + RocketPower/4+1;
       burst =(int)(Math.random()*RocketCount*3/4) + RocketCount/4+1;
       length =(int)(Math.random()*RocketBurstLength*3/4) + RocketBurstLength/4+1;
       int i;
       long seed=(long)(Math.random()*10000);
       boolean sleep;

          while(true)
             {
             try {
                 animation.sleep(100/AnimationSpeed);
                 }
             catch(InterruptedException err){}
              sleep=true;
             if(sleep&&Math.random()*100<RocketValue)
             {
       power = 200;
       burst = 100;
       length = 100;
       seed=(long)(Math.random()*10000);
        }
        random=new Random(seed);
          RocketX=new int[burst];
          RocketY=new int[burst];
          dx=150;
          dy=150;
          for(i=0;i<burst;i++)
          {
            RocketX[i]=(int)(Math.random()*power)-power/2;
            RocketY[i]=(int)(Math.random()*power*7/8)-power/8;
          }

           if(time<length)
            {
               double sl;
               Color color;

               for(i=0;i<burst;i++)
               {
                    sl=(double)time/100;
                    x=(int)(RocketX[i]*sl);
                    y=(int)(RocketY[i]*sl-Gravity*sl*sl);

                    g.setColor(Color.YELLOW);
                    g.drawLine(dx+x,dy-y,dx+x,dy-y);

                    if(time>=length/2)
                       {
                       int j;
                       for(j=0;j<2;j++)
                          {
                          sl=(double)((time-length/2)*2+j)/100;
                          x=(int)(RocketX[i]*sl);
                          y=(int)(RocketY[i]*sl-Gravity*sl*sl);

                          g.setColor(Color.black);
                          g.drawLine(dx+x,dy-y,dx+x,dy-y);
                          }
                       }
                    }

                 time++;
                 }
          }*/
            
            //Explosion = new FireworksSprite[30];
            /*for(int i = 0; i < Explosion; i++)
            {
              double a = Math.random() * 2.0f * 3.1415f;
              double r = Math.random() * 1.0f;

              double dx = Math.cos(a) * r;
              double dy = Math.sin(a) * r;

              //Explosion[i] = new Bullet(x0, y0, dx0 + dx, dy0 + dy, _g, _size, _xmax, _ymax, _trail, _life_len, _fg, _bg);
            }*/
            
	  /* AnimationSpeed = 1;
	   RocketStyleVariability = 10;
	   MaxRocketNumber = 1;
	   MaxRocketExplosionEnergy = 500;
	   MaxRocketPatchNumber = 90;
	   MaxRocketPatchLength = 150;
	   Gravity = 20;

	   bomb_Burst = new FireworksExplosionSprite[MaxRocketNumber];
	   for(int i = 0; i < MaxRocketNumber; i ++)
		   bomb_Burst[i] = new FireworksExplosionSprite(x, y, Gravity);*/

/*   int AnimationSpeed = 100;
       int RocketValue = 20;
       int RocketCount = 10;
       int RocketPower = 500;
       int RocketBurstCount = 50;
       int RocketBurstLength = 100;
       int time = 0;
       int power, burst, length;
       int dx, dy;
       int RocketX[], RocketY[];
       int Gravity = 20;
       Random random;
       mx=350;
       my=200;

       power =(int)(Math.random()*RocketPower*3/4) + RocketPower/4+1;
       burst =(int)(Math.random()*RocketCount*3/4) + RocketCount/4+1;
       length =(int)(Math.random()*RocketBurstLength*3/4) + RocketBurstLength/4+1;
       int i;
       long seed=(long)(Math.random()*10000);
       boolean sleep;

          while(true)
             {
             try {
                 animation.sleep(100/AnimationSpeed);
                 }
             catch(InterruptedException err){}
              sleep=true;
             if(sleep&&Math.random()*100<RocketValue)
             {
       power = 200;
       burst = 100;
       length = 100;
       seed=(long)(Math.random()*10000);
        }
        random=new Random(seed);
          RocketX=new int[burst];
          RocketY=new int[burst];
          dx=150;
          dy=150;
          for(i=0;i<burst;i++)
          {
            RocketX[i]=(int)(Math.random()*power)-power/2;
            RocketY[i]=(int)(Math.random()*power*7/8)-power/8;
          }

           if(time<length)
            {
               double sl;
               Color color;

               for(i=0;i<burst;i++)
               {
                    sl=(double)time/100;
                    x=(int)(RocketX[i]*sl);
                    y=(int)(RocketY[i]*sl-Gravity*sl*sl);

                    g.setColor(Color.RED);
                    g.drawLine(dx+x,dy-y,dx+x,dy-y);

                    if(time>=length/2)
                       {
                       int j;
                       for(j=0;j<2;j++)
                          {
                          sl=(double)((time-length/2)*2+j)/100;
                          x=(int)(RocketX[i]*sl);
                          y=(int)(RocketY[i]*sl-Gravity*sl*sl);

                          g.setColor(Color.black);
                          g.drawLine(dx+x,dy-y,dx+x,dy-y);
                          }
                       }
                    }

                 time++;
                 }

                //showBurst(x, y, g);
        }*/







	/*public void initBurst(Graphics2D g)
	{
           int gravity, a, v, T, L, x, y;
           explosion = new FireworksSprite[100];
           oneExplosion = new FireworksSprite();
           double valueA, valueB, dx, dy;
           int t = 0;
           Random r = new Random();
           for(t = 0; t < explosion.length; t ++)
          {
               gravity = 20;
               a = 15; //r.nextInt(5);
               v = 10; //r.nextInt(5);
               //System.out.println("a = " + a);
               //System.out.println("v = " + v);
               valueA = v*Math.sin(a)*t;
               valueB = (.5)*gravity*(t*t);
               dx = (int)v*Math.cos(a)*t;
               dy = (int)valueA - valueB;
               x = (int)dx;
               y = (int)dy;
               oneExplosion = new FireworksSprite();
               oneExplosion.setSpriteH(15);
               oneExplosion.setSpriteW(10);
               oneExplosion.setLocx(x);
               oneExplosion.setLocy(y);
               oneExplosion.setActive(true);
               oneExplosion.setVisible(true);
               oneExplosion.setVel(0, v); 
               //System.out.print("Iterating through Array" + t);
               /*explosion[t] = new FireworksSprite();
               explosion[t].setSpriteH(15);
               explosion[t].setSpriteW(10);
               explosion[t].setLocx(x);
               explosion[t].setLocy(y);
               explosion[t].setActive(true);
               explosion[t].setVisible(true);
               explosion[t].setVel(0, v); 
               for (int i = 0; i < explosion.length; i ++)
               {
                  g.setColor(Color.YELLOW);
                  g.fillOval(x, y, 25, 25);
                  //g.drawLine(x, y, x+50, y+50);
               }
           }
	}*/
/*
	public void paintBurst(Graphics2D g)
	{
          for (int i = 0; i < 100; i ++)  //explosion.length; i ++)
          {
             //explosion[i].paintSprite(g);
          }
	}*/







/*  int i;
           int e = 200;
           int p = 100;
           int l = 100;
           long s = (long)(Math.random()*10000);
           boolean sleep;
//Graphics g = getGraphics();
           while(true)
              {
                try 
              {
                 animation.sleep(20);
              }
              catch(InterruptedException x){}

              sleep=true;
              for(i=0;i<MaxRocketNumber;i++)
                 sleep=sleep&&bomb_Burst[i].sleep;
              if(sleep&&Math.random()*100<RocketStyleVariability)
                 {
                   e=200;
                   p=100;
                   l=100;
                   s=(long)(Math.random()*10000);
                 }
             }*/

Moveable
(interface)

package Fireworks;

public interface Moveable
{
   public abstract void setPosition(int x, int y);
   public abstract void setVelocity(int vx, int vy);
   public abstract void updatePosition();
}

Sprite

package Fireworks;

import java.awt.*;

abstract class Sprite
{
    protected boolean visible;
    protected boolean active;
    
    abstract void paintSprite(Graphics2D g);
    abstract void updateSprite();
    
    public boolean isVisible()
    {
        return visible;
    }
    
    public void setVisible(boolean b)
    {
        visible = b;
    }
    
    public boolean isActive()
    {
        return active;
    }
    
    public void setActive(boolean b)
    {
        active = b;
    }
    
    public void suspend()
    {
        setVisible(false);
        setActive(false);
    }
    
    public void restore()
    {
        setVisible(true);
        setActive(true);
    }
}

Sprite2D

package Fireworks;

import java.awt.*;

abstract class Sprite2D extends Sprite
{
    protected int locx;
    protected int locy;
    protected int spriteW;
    protected int spriteH;
    
    protected int xPoints[];
    protected int yPoints[];
    
    Color color;
    boolean fill;
    
    public void setLocx(int locx)
    {
        this.locx = locx;
    }
    
    public int getLocx()
    {
        return this.locx;
    }
    
    public void setLocy(int locy)
    {
        this.locy = locy;
    }
    
    public int getLocy()
    {
        return this.locy;
    }
    
     public void setSpriteH(int spriteH)
    {
        this.spriteH = spriteH;
    }
    
    public int getSpriteH()
    {
        return this.spriteH;
    }
    
    public void setSpriteW(int spriteW)
    {
        this.spriteW = spriteW;
    }
    
    public int getSpriteW()
    {
        return this.spriteW;
    }
    
    public void setFill(boolean b)
    {
        fill = b;
    }
    
    public boolean getFill()
    {
        return fill;
    }
    
    public boolean isFill()
    {
        return getFill();
    }
    
    public void setColor(Color c)
    {
        color = c;
    }
    
    public Color getColor()
    {
        return color;
    }
}

Okay, I created this file for the Constants class. It might be better to have the real Constants (these are just random numbers):

package Fireworks;

public class Constants
{
     static int SPEED = 3000;
     static int WIDTH = 500;
     static int HEIGHT = 500;
     static int FIREWORKS_COUNT = 500;
     static int SPINNER_COUNT = 500;
     static int ROCKET_COUNT = 500;
     // Constants.SONG I left blank since I don't know what type it is.
}

It won't compile without the SongSprite and InstructionsPanel classes though.

Okay, I created this file for the Constants class. It might be better to have the real Constants (these are just random numbers):

package Fireworks;

public class Constants
{
     static int SPEED = 3000;
     static int WIDTH = 500;
     static int HEIGHT = 500;
     static int FIREWORKS_COUNT = 500;
     static int SPINNER_COUNT = 500;
     static int ROCKET_COUNT = 500;
     // Constants.SONG I left blank since I don't know what type it is.
}

It won't compile without the SongSprite and InstructionsPanel classes though.

Sorry 'bout that. Didn't think about that part. Here are those classes below.

Constants

public class Constants 
{
    static public int WIDTH = 800;
    static public int HEIGHT = 800;
    static public int SPEED = 1000;
    static public int ROCKET_HEIGHT = 10;
    static public int ROCKET_WIDTH = 2;
    static public int FIREWORKS_COUNT = 10;
    static public int SPINNER_COUNT = 10;
    static public int ROCKET_COUNT = 10;
    static public String SONG = "WilliamTell.wav";
    static public String BANG = "fireworks.wav";
    
    
    public Constants() 
    {
    }
    
}

SongSprite

import java.io.IOException;
import java.text.DecimalFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip ;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException ;
import javax.sound.midi.*;
import javax.sound.sampled.*;
import java.applet.AudioClip;
import java.util.*;
import java.applet.*;
import javax.swing.*;
import java.io.*;
import java.net.*;

 

public class SongSprite implements LineListener
{
    private String name;
    private Clip SongClip;
    private String file;
    private DecimalFormat df;
   
   
    public SongSprite()
    {  
    }
   
    public void setFilename(String Songfile)
    {
        this.file = file;
    }
   
    public String getFilename()
    {
        return file;
    }
    
   
    /*public void loadClip()
    {

  try
          {
               Sequence midiSong = MidiSystem.getSequence(getClass().getResource("WilliamTell.mid"));
               Sequencer midiSequence = MidiSystem.getSequencer();
               midiSequence.setSequence(midiSong);
               midiSequence.open();
               midiSequence.start();
          } catch (MalformedURLException e) {
          } catch (IOException e) {
          } catch (InvalidMidiDataException e) {
          } catch (MidiUnavailableException e) {}
      }  
      */   
/*          try
          {
              AudioClip FireworkSound = Applet.newAudioClip (getClass().getResource(filename));
              FireworkSound.play ();
          }
          catch(Exception e)
          {
              System.out.println("Problem with " + filename);
          }*/
          //URL url = getClass().getResource(explosion);
          //getAudioClip(url).play();
          //getAudioClip(url).loop();
    
   
   
    public void update(LineEvent SoundEvent)
    {   
            SongClip.stop();
            SongClip.setFramePosition(0);
            SongClip.start();   
    }
   
    public void close(){
        if(SongClip != null){
            SongClip.stop ();
            SongClip.close();
        }
    }
   
    public void play()
    {
        if(SongClip != null)
        {
            SongClip.start();
        }
        //else
          //System.out.Println("Invalid file selected.");
    }
   
   
    public void stop()
    {
        if(SongClip != null)
        {
            SongClip.stop();
        }
        //else
         //System.out.Println("Invalid file selected.");
    }
   
    public void pause()
    {
        if(SongClip != null)
            SongClip.stop();
        //else
         //System.out.Println ("Invalid file selected.");
    }
   
    public void resume()
    {
        if(SongClip != null)
            SongClip.start();
        //else
         //System.out.Println("Invalid file selected.");
    }
}

InstructionsPanel

import java.awt.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.*;
import java.awt.Container;
import javax.swing.*;
import javax.swing.JButton;
import javax.imageio.ImageIO;

public class InstructionsPanel extends javax.swing.JPanel 
{    
    Fireworks Game;
    //Graphics g;
    

    public InstructionsPanel() 
    {
        initComponents();
        //paintComponent(g);
    }
    
    
    public void setGame(Fireworks Game)
    {
         this.Game = Game;
    }
    
    // Variables declaration - do not modify                     
    // End of variables declaration                   
    
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D)g;
        g2d.setFont(new Font("TimesRoman", Font.BOLD,20));
        g2d.setColor(Color.BLACK);

        g2d.setFont(new Font("Times New Roman", Font.BOLD, 15));
        g2d.drawString("Fireworks Display", Constants.WIDTH/2 + 20, Constants.HEIGHT/2);
        g2d.drawString("Story Line: It is time for your town's annual Fireworks show.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 40);
        g2d.drawString("As a new Pyrotechnics expert in the region, you have been hired to conduct this year's festivities.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 60);
        g2d.drawString("Due to past shows, the audience will be a hard sale to please.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 80);
        g2d.drawString("Earn points for each display and make the crowd happy.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 100);
        g2d.drawString("Will you succeed where others have failed?", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 120);

        g2d.drawString("Instructions.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 160);
        g2d.drawString("Please click on a Firework type to launch a show to display.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 180);
        g2d.drawString("Each type of show earns points for the user.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 200);
        g2d.drawString("The objective is to reach a total of 100 points from Fireworks.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 220);
        g2d.drawString("Fireworks Rockets Show (Keyboard Letter C) -> 5 points.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 240);
        g2d.drawString("Fireworks Spinners show (Keyboard Letter V)  -> 10 points.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 260);
        g2d.drawString("Finale show (all types) (Keyboard Letter B)  -> 15 points.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 280);
    }   
  
    
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
    private void initComponents() {
        jButton1 = new javax.swing.JButton();

        jButton1.setText("Back");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jButton1)
                .addContainerGap(335, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jButton1)
                .addContainerGap(266, Short.MAX_VALUE))
        );
    }// </editor-fold>                        

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        Game.Back();
    }                                        
    
    
    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    // End of variables declaration                   
    
}

Had to comment out the "org.jdesktop.layout.GroupLayout" lines since my NetBeans installation couldn't find them. I uncommented the "Fireworks.java" main function and ran that (I assume that's the main file to run?). I see no calls to the AbsFireworksPanel "run" function, so it's not just the println command that's not being implemented. The entire "run" function is not called. So I'm not sure which "main" is supposed to be implemented, where "run" is supposed to be called from for AbsFireworksPanel, and like I said, at least my Java installation can't handle the "org.desktop.layout.GroupLayout" lines since it can't find that package.

Had to comment out the "org.jdesktop.layout.GroupLayout" lines since my NetBeans installation couldn't find them. I uncommented the "Fireworks.java" main function and ran that (I assume that's the main file to run?). I see no calls to the AbsFireworksPanel "run" function, so it's not just the println command that's not being implemented. The entire "run" function is not called. So I'm not sure which "main" is supposed to be implemented, where "run" is supposed to be called from for AbsFireworksPanel, and like I said, at least my Java installation can't handle the "org.desktop.layout.GroupLayout" lines since it can't find that package.

I should have mentioned what IDE I'm using.....Sun Java Studio Enterprise 8.1 (it generates some of the stuff that your system didn't like).

As for the primary file, the fireworks.java is the correct one. I'll look through the run() statement again, but it should only be handling the outer instantiation of the program (start game, end game, blah blah).

I'll still have this window up if you have any questions......I'm *STILL* trying to figure this mess out.

I should have mentioned what IDE I'm using.....Sun Java Studio Enterprise 8.1 (it generates some of the stuff that your system didn't like).

As for the primary file, the fireworks.java is the correct one. I'll look through the run() statement again, but it should only be handling the outer instantiation of the program (start game, end game, blah blah).

I'll still have this window up if you have any questions......I'm *STILL* trying to figure this mess out.

Well, your test line:

System.out.println("TEST EXPLODE!!");

is in the run function of AbsFireworksPanel and you were saying it doesn't print, so if that function is never called from anywhere, it's no surprise that it doesn't print. If all you want it to do is handle the outer stuff and it has nothing to do with where the explosion is being painted, maybe you should have your run function with the Thread sleep in the Fireworks class and take it out of AbsFireworksPanel.

Well, your test line:

System.out.println("TEST EXPLODE!!");

is in the run function of AbsFireworksPanel and you were saying it doesn't print, so if that function is never called from anywhere, it's no surprise that it doesn't print. If all you want it to do is handle the outer stuff and it has nothing to do with where the explosion is being painted, maybe you should have your run function with the Thread sleep in the Fireworks class and take it out of AbsFireworksPanel.

I've tried placing a run() function in the extended class, but it doesn't do any good (only result was a black screen, and no score paint, or firework, or anything). I also tried getting rid of run entirely from the outer class and use it in the inner class; that too was a bust. The only reason the outer function has the println right now was that I was trying to attempt to "piggy-back" the code; have the thread support the extended class, while also working on the ABS class (hey, desperate attempt, I know). Of course, it too was a bust.

Well, your test line:

System.out.println("TEST EXPLODE!!");

is in the run function of AbsFireworksPanel and you were saying it doesn't print, so if that function is never called from anywhere, it's no surprise that it doesn't print. If all you want it to do is handle the outer stuff and it has nothing to do with where the explosion is being painted, maybe you should have your run function with the Thread sleep in the Fireworks class and take it out of AbsFireworksPanel.

Played with the code more. The run() works up to updateGame() call. The rest of the function works fine.

Is there a way to create a buffered image inside a JPanel instead of an applet? Was going through looking around for this, but the code doesn't like what I'm trying from the books.
Any references or ideas?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.