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

  • Home
  • SEARCH
  • 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 8021283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:55:52+00:00 2026-06-04T21:55:52+00:00

Here is my applet class: package DavidPackages.Prototypes.Samples.BubblesV2SSCCE; import java.applet.Applet; import java.awt.*; import java.awt.geom.Ellipse2D; import

  • 0

Here is my applet class:

package DavidPackages.Prototypes.Samples.BubblesV2SSCCE;

import java.applet.Applet;
import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.util.ArrayList;
import java.util.Random;

public class BubbleAppletV2SSCCE extends Applet implements Runnable{

    private Thread thread;
    private ArrayList<Ellipse2D> circles;

    public void init(){
        //Initialize bubbles with one entry so that we have a bubble to start out with
        Random r = new Random();
        circles = new ArrayList<Ellipse2D>();
        circles.add(new Ellipse2D.Float(5, 5, 15, 15));

        thread = new Thread(this);
        thread.start();
    }

    public void run(){
        while(true){

            update();
            repaint();

            try{
                Thread.sleep(10);
            }catch(InterruptedException ie){
                ie.printStackTrace();
            }
        }
    }

    private void update(){
        circles.add(new Ellipse2D.Float(5, 5, 15, 15));
    }

    public void paint(Graphics graphics){
        for(Ellipse2D circle : circles){
           ((Graphics2D) graphics).draw(circle);
        }
    }

    public void stop(){}
}

Here is the stack trace:

Exception in thread "AWT-EventQueue-1" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
at java.util.AbstractList$Itr.next(AbstractList.java:420)
at DavidPackages.Prototypes.Samples.BubblesV2SSCCE.BubbleAppletV2SSCCE.paint(BubbleAppletV2SSCCE.java:43)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
at sun.awt.RepaintArea.paint(RepaintArea.java:241)
at apple.awt.ComponentModel.handleEvent(ComponentModel.java:268)
at java.awt.Component.dispatchEventImpl(Component.java:4159)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3918)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:501)
at java.awt.EventQueue.access$000(EventQueue.java:80)
at java.awt.EventQueue$1.run(EventQueue.java:462)
at java.awt.EventQueue$1.run(EventQueue.java:461)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:84)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:95)
at java.awt.EventQueue$2.run(EventQueue.java:476)
at java.awt.EventQueue$2.run(EventQueue.java:475)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:84)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:473)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

The only call here that’s in my code is:

    at DavidPackages.Prototypes.Samples.BubblesV2SSCCE.BubbleAppletV2SSCCE.paint(BubbleAppletV2SSCCE.java:43) 

which is this line:

        for(Ellipse2D circle : circles){

More Details:

  • I’m running this in IntelliJ IDEA 10.5.4
  • I’m running this on a Mac running OSX 10.5.8
  • The exception is more likely to be thrown when there are more instances of Bubble in bubbles
  • The exception is more likely to be thrown when multiple instances of the applet are running

I’m confused because I don’t see how I’m modifying the contents of bubbles while control is in that for loop.

Does anyone have any ideas?

Bonus Questions:

  • My intention is to eventually have created a game that runs on someones machine, and not in a web browser. What should I be using for this other than an applet?
  • What should I be using instead of AWT?

In regard to the second bonus question up there. I found this article which says that:

AWT provides a rich graphics environment, especially in Java V1.2 and beyond. Through the Graphics2D object, and Java2D and Java3D services, many powerful graphical applications, such as drawing and charting packages and, combined with JavaSound, competitive interactive games, can be created.

This leads me to believe that AWT is indeed right for me. Or is the author mistaken? The article is from 2006 so it’s a little dated but not much.

UPDATES (stuff that wasn’t in the original post):

  • Long block of commented out code removed
  • Updated my example
  • Added bonus questions
  • Added quote from article comparing AWT and Swing and SWT
  • 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-06-04T21:55:55+00:00Added an answer on June 4, 2026 at 9:55 pm

    You are not changing the content of bubbles in the paint method, but you are changing them in the run method, and that method is executed in a separate thread. That explains why you don’t always get that exception, it only happens when paint just happens to be executed at the same time that you are changing the list bubbles in another thread.

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

Sidebar

Related Questions

here is my code... package sortarray.com; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle;
Here is my code: public class Main extends Applet implements Runnable, KeyListener, java.awt.event.MouseListener {
OK so here's the code: import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; public class Main
I am having trouble with a HelloWorld Applet. Here is my Java code: package
Here is my object tag. <object classid=java:my.full.class.Name.class height=360 width=320> <param name=type value=application/x-java-applet> <param name=archive
I have a Java Applet compiled in Eclipse using Swing. See here: http://www.test.world2build.com/Game/Play.aspx For
I have written a Java applet class and made a small HTML page to
This may be old error but I am stuck here. I created Java applet
I'm creating a Java applet from a large scale pre-existing project (Vizster). I am
I am writing a StringOutputStream class in Java because I need the pre-Base64-encoded data

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.