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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:40:32+00:00 2026-05-14T04:40:32+00:00

Can JPanel s background be set to transparent? My frame is has two JPanel

  • 0

Can JPanels background be set to transparent?

My frame is has two JPanels:

  • Image Panel and
  • Feature Panel.

Feature Panel is overlapping Image Panel.
The Image Panel is working as a background and it loads image from a remote URL.

On Feature Panel I want to draw shapes. Now Image Panel cannot be seen due to Feature Panel’s background color.

I need to make Feature Panel background transparent while still drawing its shapes and I want Image Panel to be visible (since it is doing tiling and cache function of images).

I’m using two JPanel‘s, because I need to seperate the image and shape drawing .

Is there a way the overlapping Jpanel have a transparent background?

  • 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-14T04:40:33+00:00Added an answer on May 14, 2026 at 4:40 am

    Alternatively, consider The Glass Pane, discussed in the article How to Use Root Panes. You could draw your “Feature” content in the glass pane’s paintComponent() method.

    Addendum: Working with the GlassPaneDemo, I added an image:

    //Set up the content pane, where the "main GUI" lives.
    frame.add(changeButton, BorderLayout.SOUTH);
    frame.add(new JLabel(new ImageIcon("img.jpg")), BorderLayout.CENTER);
    

    and altered the glass pane’s paintComponent() method:

    protected void paintComponent(Graphics g) {
        if (point != null) {
            Graphics2D g2d = (Graphics2D) g;
            g2d.setRenderingHint(
                RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, 0.3f));
            g2d.setColor(Color.yellow);
            g2d.fillOval(point.x, point.y, 120, 60);
        }
    }
    

    enter image description here

    As noted here, Swing components must honor the opaque property; in this variation, the ImageIcon completely fills the BorderLayout.CENTER of the frame’s default layout.

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

Sidebar

Related Questions

I have a JPanel for which I set some image as the background. I
How can i make AWT component transparent when the background is progressive image? Note:
In my JPanel , I set the background of a JLabel to a different
How can I tell the paint method to draw background on JPanel only and
I'm drawing a transparent rendered image on top of a background image which is
How can i completely make this grey panel as transparent , so that i
How can I draw something in JPanel that will stay the same and not
Can a LINQ enabled app run on a machine that only has the .NET
I'm having A JLayeredPane where I add 3 JPanels. I make the JPanels transparent
I am attempting to overlay images on top of a background image using the

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.