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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:13:09+00:00 2026-06-18T07:13:09+00:00

I have the following Java Swing problem: a parent panel doesn’t get painted (i.e.

  • 0

I have the following Java Swing problem: a parent panel doesn’t get painted (i.e. paintComponent() not even called) when it is covered by another panel which has a transparent background.

I guess this behavior is normal if the child panel isn’t transparent but here it is an issue since the parent panel provides a picture as background.

Probably not relevant but you never know: child panel is a ChartPanel from JFreeChart’s library (extends JPanel) and parent panel is also a JPanel extension, hereby the paintComponent code:

@Override

public void paintComponent(Graphics g) {
    try {
        long start = System.currentTimeMillis();

        //Sets waiting cursor
        GuiHelper.setCursorOnEntireWindow(Cursor.WAIT_CURSOR);

        //Paints parent
        super.paintComponent(g);

        //Paints background and other elements
        g.drawImage(generateBackground(getWidth(), getHeight()), 0, 0, getWidth(), getHeight(), this);

        long end = System.currentTimeMillis();
        System.out.println("Chart paint took: "+(end-start)+"ms");
    }
    finally { 
        //Removes waiting cursor
        GuiHelper.setCursorOnEntireWindow(Cursor.getDefaultCursor().getType()); 
    }       

}

Any help/hint would be greatly appreciated as I’ve been looking into for hours now.

Thanks!

  • 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-18T07:13:10+00:00Added an answer on June 18, 2026 at 7:13 am

    a parent panel doesn’t get painted (i.e. paintComponent() not even called) when it is covered by another panel which has a transparent background

    Not sure how you are setting the transparent background of ChartPanel. I think you just need to use:

    childPanel.setOpaque(false);
    

    If this doesen’t work then check out Background With Transparency for more information on how painting is done between child/parent components.

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

Sidebar

Related Questions

Say I have the following code: import java.lang.InterruptedException; import javax.swing.SwingWorker; public class Test {
I am new to Java, started learning swing and have a problem with resizing
I have a simple problem with my JPanel / Gridbaglayout: import javax.swing.*; import java.awt.*;
I have problem running the following code, it says Error: Could not find or
I have a javax.swing.JPanel called calcResPanel (using a java.awt.GridLayout with 1 column and indefinite
I have an annoying problem with Java’s layout managers. I have the following situation:
I have a problem with understanding the following code: import java.awt.Dimension; import java.awt.GridLayout; import
I have the following java code: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;
I have the following Java code: final Future future = exeService.submit( new Runnable() {
Say suppose I have the following Java code. public class Example { public static

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.