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

On researching another question I noted that the stat function in Perl can take
Over the last few days I have noted a few web sites that demonstrated
I have noted over the years, that I tend to write maybe a screen
Note that I am not asking which to choose (MVC or MVP), but rather
Note that this function does not have a { and } body. Just a
I have a dialog that resizes. It also has a custom background which I
Please note that this question is about CGLayer (which you typically use to draw
Question: I need to draw pictures as below in C#/VB.NET Note that my problem
My busy loading indicator basically works by detecting clicks. However, I just noted that
I wish to draw an image based on computed pixel values, as a means

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.