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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:12:36+00:00 2026-06-10T00:12:36+00:00

I am using Graphics to draw ovals on a JPanel. Something is happening with

  • 0

I am using Graphics to draw ovals on a JPanel. Something is happening with the lowest oval, which, instead of staying one colour, is multiple colours in stripes across the oval. This doesn’t happen with the other ovals.

My JFrame size is 600 by 600.
Here is my code:

package virus;

import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.event.MouseListener;
import java.util.Random;

public class VirusGamePanel extends JPanel {
    private static final long serialVersionUID = 1L;
    Random colour = new Random();
    int score = 0;

    public void paint(Graphics g)
    {
        super.paint(g);
        g.setColor(Color.magenta);
        g.drawString("Score: "+ score,200,200);
        g.setColor(Color.orange);
        g.drawOval(200,150,200,200);
        Color rand = new Color(colour.nextInt(255),colour.nextInt(255),colour.nextInt(255));
        g.setColor(rand);
        g.fillOval(270,50,50,50);
        g.fillOval(100,100,50,50);
        g.fillOval(450,100,50,50);//this line is causing the problem
        g.fillOval(100,400,50,50);
    }
}
  • 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-10T00:12:37+00:00Added an answer on June 10, 2026 at 12:12 am

    I wrote a small test program that draws your panel in a JFrame and everything looks fine for me (I have no stripes). I’m using Java 7. Maybe your error is in an other part of your program :).

    Do you get the same error with this program?

    import javax.swing.*;    
    import java.awt.*;
    import java.util.Random;
    
    public class VirusGamePanel extends JPanel {
        private static final long serialVersionUID = 1L;
        Random colour = new Random();
        int score = 0;
    
        public void paint(Graphics g)
        {
            super.paint(g);
            g.setColor(Color.magenta);
            g.drawString("Score: "+ score,200,200);
            g.setColor(Color.orange);
            g.drawOval(200,150,200,200);
            Color rand = new Color(colour.nextInt(255),colour.nextInt(255),colour.nextInt(255));
            g.setColor(rand);
            g.fillOval(270,50,50,50);
            g.fillOval(100,100,50,50);
            g.fillOval(450,100,50,50);//this line is causing the problem
            g.fillOval(100,400,50,50);
        }
    
        public static void main(String[] args) {
            JFrame f=new JFrame();
            f.setSize(600,600);
            f.add(new VirusGamePanel());
            f.setVisible(true);
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I want to draw a circle using Graphics, but instead of using integers
I want to draw string using Graphics with Rectangle border outside the string. This
Using core graphics , I am trying to draw a line, in that when
I try to draw rain and snow as particle system using Core Graphics .
I am trying to draw some basic graphics primitives(line, rectangle etc.) using GDI+ apis
Assuming I'm using some graphic API which allows me to draw bezier curves by
I am trying to produce some example graphics using ggplot2, and one of the
We are using graphics context of a form to draw an image. However it
I've been using BitmapData.copyPixels() to draw graphics onto a canvas ( Bitmap ). I
Is it possible to write/draw graphics (3D & 2D) using Visual C++ 2010 Express?

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.