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 8578021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:17:33+00:00 2026-06-11T20:17:33+00:00

My problem is the following. I am using the standard SWING event dispatch thread

  • 0

My problem is the following. I am using the standard SWING event dispatch thread to draw an oval with a low alpha value and another smaller oval in the centre to represent its centre. And when I run the simulation, I use a separate thread and also allow the user to add these obstacles while the simulation is running. Now this works fine when the separate thread isn’t running but when the separate simulation thread is running, the bigger oval (Which is supposed to be drawn with a low alpha) isn’t drawn with a low alpha value and therefore creates a solid big red oval. Why is this happening and how can I resolve this?

If i wasn’t too clear in my explanation please let me know.

private void drawObstacleCircle(Obstacle o, Graphics2D g)
{
    final double OBSTACLE_CENTER_RADIUS = 2.0;
    final double OBSTACLE_RADIUS = o.getRadius(true);

    float scaleToUse = Math.max(0.8f, scale);

    Vector pos = o.getPosition();

    int xPos = (int) (pos.getX() * getBufferedHeightMap().getWidth());
    int yPos = (int) (pos.getY() * getBufferedHeightMap().getHeight());

    Point positionPoint = convertToPanelPoint(new Point(xPos, yPos));

    // Draw the circle where the Obstacle's center is
    Graphics2D g1 = (Graphics2D) g.create();

    g1.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g1.setColor(Color.RED);
    g1.fillOval(positionPoint.x - (int) (OBSTACLE_CENTER_RADIUS * scaleToUse), positionPoint.y - (int) (OBSTACLE_CENTER_RADIUS * scaleToUse), (int) (OBSTACLE_CENTER_RADIUS * 2 * scaleToUse), (int) (OBSTACLE_CENTER_RADIUS * 2 * scaleToUse));

    Color c = Color.RED;
    g1.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 100));
    g1.fillOval(positionPoint.x - (int) (OBSTACLE_RADIUS * scaleToUse), positionPoint.y - (int) (OBSTACLE_RADIUS * scaleToUse), (int) (OBSTACLE_RADIUS * 2 * scaleToUse), (int) (OBSTACLE_RADIUS * 2 * scaleToUse));

    g1.dispose();
    g2.dispose();
}
  • 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-11T20:17:34+00:00Added an answer on June 11, 2026 at 8:17 pm

    It’s hard to tell without the code around it, but it seems to me like you aren’t erasing your canvas before you start redrawing the scene. Could the addition of the new thread cause the drawObstacleCircle method to be called multiple times with the same graphics context?

    That would mean that the method draw on top of the already drawn scene. So a slightly transparent oval is drawn again and again and again on place of the previously drawn ovals until the area looks solid red.

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

Sidebar

Related Questions

I'm having the following problem using the Visual Studio 2010 Team System Beta 1:
I experience the following problem while using legacy VC6. I just cann't switch to
I'm having the following problem when using GWT and request factory. I am working
I have the following problem in a Database using Access 2007 as front end
I am using following query which works fine for me except one problem SELECT
I'm facing following problem actually: I'm using Spring with jQuery. I have Controller: @Controller
I got the following problem: In my Android App I am using a table
I have a problem creating the following SQL Statement using LINQ & C# select
I have a following problem: I compiled my application on Linux Ubuntu 9.10 using
I am using CSS rounded corners for firefox and I have the following problem

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.