Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3241488
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:12:16+00:00 2026-05-17T18:12:16+00:00

I have a school project and i want to dedicate this for New Year,

  • 0

I have a school project and i want to dedicate this for New Year, the project that i came up is a Text-Firework, i am using characters and symbols as the Explosion particles, and just constantly changing their X and Y position inside Paint().
I am confused on how to use Paint and Thread together. The problem is it’s not painting on the screen or maybe the thread is not starting. (i cant really tell, im sorry). the problem is i dont get any error, it just doesn’t work 🙁

the code is a little bit long i think, thank you for reading it.

How it should Works: When a user click, a Firework Thread will be started on the mouse position,
this Firework class has a paint loop for recreating the incremental explosion. so basically, i want the user to create multiple explosions thats why i made it a Thread.

here is the main applet:

public class TBFireworks extends Applet implements MouseListener
{
    public void init()
    {
        setBackground( Color.black );
        addMouseListener( this );
    }

    public void mouseEntered( MouseEvent e ) { }
    public void mouseExited( MouseEvent e ) { }
    public void mousePressed( MouseEvent e ) { }
    public void mouseReleased( MouseEvent e ) { }
    public void mouseClicked( MouseEvent e ) 
    {
        new Firework( e.getX(),e.getY(), this);
    }
}

and the Firework Thread class:

class Firework extends Thread
{
    Point center = new Point(0,0);
    int blastRadius = 10;
    Point posIncrement = new Point(0,0);
    Applet applet;

    public Firework(int positionX, int positionY, Applet apple)
    {
        center.x = positionX;
        center.y = positionY;
        applet = apple;
        new Thread(this).start();
    }

    public void run()
    {
        while(blastRadius > 0)
        {
            applet.paint(applet.getGraphics());

            try {
                this.sleep(1000/20);
            } catch (InterruptedException e) { ; }
        }
    }

    public void paint(Graphics g)
    {
        if(blastRadius > 0)
        {
            Point[] fakeFire = {new Point(20,20),new Point(20,30),new Point(30,20)};
            ApplyNextPos(fakeFire,posIncrement);

            g.setColor(Color.red);
            for(int xaa=1; xaa<5; xaa++) // draw the formation
            {
                for(int zaa=0;zaa<fakeFire.length;zaa++)
                {
                    fakeFire[zaa] = GetQuadrant(xaa,center,fakeFire[zaa]);
                }

                for(int yaa=0;yaa<fakeFire.length;yaa++)
                {
                    g.drawString("*",fakeFire[yaa].x,fakeFire[yaa].y);
                }
            }
            posIncrement.incrementPos(5);
            blastRadius--;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:12:17+00:00Added an answer on May 17, 2026 at 6:12 pm

    First, you seem not to be using your paint-method in the FireWork thread, you call the applet’s paint method instead.

    I’m a bit rosty in the applet and AWT stuff, but if it were Swing (I guess it not that different), I would suggest another approach. Painting should (can?) only be done in the EDT (Event Dispatch Thread). When the user clicks, you create a similar object to FireWork, and add that to a list. Then you start ONE thread (if not already started, that continously calls repaint on some panel. Then in the paint-method of your panel you loop the list of all fireworks and draw them.

    This will also be more memory efficient, since you only use one thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple python files for a school project that I want to open
I have a school project to program multilayer perceptron that classify data into three
We have been using Google Code SVN to store a school project. As we
I have created a MazeSolver android app for a school project. I am using
I'm the network programmer on a school game project. We want to have up
I have a school project, for which I want to develop a web application
I am a newbie to Hibernate. I have a school project using MySQL, JDBC,
I have a group project for school that I am working on. A member
Basically I have a school project where I must create a new wave file
I have a school project in which I have to implement a chat application,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.