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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:54:58+00:00 2026-06-16T09:54:58+00:00

import java.applet.*; import java.awt.*; // Graphics, Shape import java.awt.geom.*; //Graphics2D /* <applet code =

  • 0
import java.applet.*;
import java.awt.*;      // Graphics, Shape
import java.awt.geom.*; //Graphics2D
/*
<applet code = Oval1.class height=300 width=300 >
</applet>
*/
public class Oval1 extends Applet implements Runnable {
    Shape circle;
    Color c;
    public void init() {
        circle = new Ellipse2D.Float(90,100, 90, 90);
        repaint();
        Thread th = new Thread(this);
        th.start();
    }
    public void run() {
        try {
            while(true) {
                System.out.println(1);
                c = Color.cyan;
                repaint();
                Thread.sleep(1000);
                System.out.println(2);
                c = Color.gray;
                repaint();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    public void update(Graphics g) {
        paint(g);
    }
    public void paint(Graphics g) {
        Graphics2D d = (Graphics2D) g;
        d.setColor(c);
        d.fill(circle);
    }
}

I am trying to create an applet that has a filled circle in middle of the applet & changing the color of circle in every second, means I want to show the circle like it’s blinking.

I want to change color of circle in every second.

For this I use Shape class & Thread, but it’s still not working.

I already try by using paint(g) by overriding update method..

This will not also effect

  • 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-16T09:55:00+00:00Added an answer on June 16, 2026 at 9:55 am

    Add Thread.sleep(1000) after second repaint().

            while(true) {
    
                System.out.println(1);
                c = Color.cyan;
                repaint();
                Thread.sleep(1000);
                System.out.println(2);
                c = Color.gray;
                repaint();
                Thread.sleep(1000);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is the code: import java.awt.*; import java.applet.*; public class anim1 extends Applet{ public
this is the code: import java.awt.*; import java.awt.event.*; import java.applet.*; import java.util.Vector; public class
Looking at some code, learing about threads : import java.applet.*; import java.awt.*; public class
package homework1; import java.applet.Applet; import java.awt.Graphics; public class Homework1A extends Applet { public void
package javaapplication3; import java.applet.Applet; import java.awt.*; /*<applet code=NewApplet width=3000 height=80> <param name=fontName value=Courrier></applet>*/ public
import java.awt.*; import java.applet.*; public class Appletdemo extends Applet { TextField text1,text2; public void
import java.awt.Graphics; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JApplet; import javax.swing.Timer; public class
Here is my applet class: package DavidPackages.Prototypes.Samples.BubblesV2SSCCE; import java.applet.Applet; import java.awt.*; import java.awt.geom.Ellipse2D; import
import java.awt.*; import javax.swing.*; import javax.swing.GroupLayout; /** * @author Ene Ion */ public class
The following is the condensed code of my applet game: import java.applet.Applet; import java.awt.event.*;

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.