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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:30:22+00:00 2026-05-14T06:30:22+00:00

I noted that when i draw something with Color(0,0,0,0), which is over another image,

  • 0

I noted that when i draw something with Color(0,0,0,0), which is over another image, the color shown is the JFrame background, not the image just below it.

Reasons that’d help me to find a solution?

Thanks!!

Edit: See the circles, the grey area (corners) should be transparent but are not, instead, they are the color of the JFrame.
alt text http://img72.imageshack.us/img72/9657/transparency.png

And here is the code to draw the circles:

public void paint(final Graphics g) {
        super.paintComponent(g);
        final Graphics2D g2 = (Graphics2D) g;

        RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        if (unitImage == null) {

            unitImage = (BufferedImage) (createImage(30, 30));
            final Graphics2D gc = unitImage.createGraphics();
            gc.setRenderingHints(rh);
            gc.setColor(outsideColor);
            gc.fillOval(0, 0, diameter, diameter);
            gc.setColor(middleColor);
            gc.fillOval(diameter / 6, diameter / 6, (diameter / 3) * 2, (diameter / 3) * 2);
            gc.setColor(innerColor);
            gc.fillOval(diameter / 3, diameter / 3, diameter / 3, diameter / 3);
        }

        g2.drawImage(unitImage, null, 0, 0);

Been toying with the Alphacomposites, i think its not the solution. So i added all this new info which i believe, will help you guys to give me another tip.

  • 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-14T06:30:22+00:00Added an answer on May 14, 2026 at 6:30 am

    @Chuk Lee is right: Unless you change it, the default Graphics2D composite is AlphaComposite.SrcOver. This handy tool displays the composite result for a selected rule and a specified pair of color and alpha.

    Addendum: One approach is to override paintComponent() and render both map and circles, but you might be able to make the corners transparent by clearing the alpha:

    ...
    gc.setRenderingHints(rh);
    gc.setComposite(AlphaComposite.Clear);
    gc.fillRect(0, 0, diameter, diameter);
    gc.setComposite(AlphaComposite.Src);
    gc.setColor(outsideColor);
    ...
    

    Does createImage(30, 30) relate to diameter? For what component do you override paint() and invoke super.paintComponent(g)?

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

Sidebar

Related Questions

Question: I need to draw pictures as below in C#/VB.NET Note that my problem
I have a dialog that resizes. It also has a custom background which I
I noted that when I show up the EOL listchars in a text the
I'm moving from adobe flex to ext js 4, and I noted that in
I noted recently that google maps now includes a border for a postcode and
Edit : Note that, as Daniel and latkin noted in an answer and a
(note that this question is not about CAS, it's about the May fail spuriously
I'm new to database design and I considering implementing something that will be time
In a SurfaceView, I'm dispatching new thread that draws on canvas within standard LockCanvas-Draw-unlockCanvasAndPost
A brief background: I'm working on a web-based drawing application and need to draw

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.