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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:26:19+00:00 2026-05-19T12:26:19+00:00

So here’s the deal: I’ve got a JPanel and a JTextArea inside that one.

  • 0

So here’s the deal:

I’ve got a JPanel and a JTextArea inside that one. The JPanel has a background color which has an alpha value of 200, ie. you can paritally see the background image through the JPanel. Ain’t that called partial transparency? Anyway, then I’ve set the JTextArea non-opaque, so that I can fully see through that one:

JPanel p = new JPanel();
p.setBackground(new Color(237, 234, 215, 200);
JTextArea jta = new JTextArea("Blahblahblahblah");
jta.setOpaque(false);
p.add(jta);

Ok, so when I hit a button, the text will be changed like this:

jta.setText("new BlahBlah...");

Then it happens: the first text remains back there with a new partially transparent film on it. And the text I added, comes on top of course, but right there behind you can see the previous one. When I change the text some few times more, the ghost disappears.

The screenshot as a link.

Translation (the screenshot has 3 shots on a row):
Left one: “Question # 1 out of 8: (a political question)? (My comment: OK)”
Center: “Question # 2 out of 8: (another question, never mind)? (My comment: The ghost is there! [and the arrow pointing it out])”
Right-hand side: “Question # 8 out of 8: (another question)? (My comment: OK)”

If I reduce the amount of questions this program swaps, from 8 to 3, for example, the last one looks usually good, the ghost is gone. But sometimes it sticks on no matter what I do. Could it possibly have something to do with not enough memory (I hardly swallow that, though)?

So, please help me out, dudes! I’ve got the deadline in 48 hrs.

PS. In case you wonder, that language is Finnish. I’m working on a school project: It’s gonna be a comparing machine that can have a variety of applications: For example, if you have a public election coming, the press/media may use this kind of machine on the web to get the candidate’s opinions on whatever issues, and then voters may enter their opinions too, and the machine calculates which candidates match the voter’s thoughts best. See my homepage, ie. the project blog (Finnish) for more screenshots in case you’re interested.

an55i

  • 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-19T12:26:20+00:00Added an answer on May 19, 2026 at 12:26 pm
    p.setBackground(new Color(237, 234, 215, 200);
    

    Swing does not support transparent backgrounds.

    Swing expects a component to be either:

    1. opaque – which implies the component will repaint the entire background with an opaque color first before doing custom painting, or
    2. fully transparent – in which case Swing will first paint the background of the first opaque parent component before doing custom painting.

    The setOpaque(...) method is used to control the opaque property of a component.

    In either case this makes sure any painting artifacts are removed and custom painting can be done properly.

    If you want to use tranparency, then you need to do custom painting yourself to make sure the background is cleared.

    The custom painting for the panel would be:

    JPanel panel = new JPanel()
    {
        protected void paintComponent(Graphics g)
        {
            g.setColor( getBackground() );
            g.fillRect(0, 0, getWidth(), getHeight());
            super.paintComponent(g);
        }
    };
    panel.setOpaque(false); // background of parent will be painted first
    

    Similar code would be required for every component that uses transparency.

    Or, you can check out Background With Transparency for custom class that can be used on any component that will do the above work for you.

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

Sidebar

Related Questions

Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Here's a problem I ran into recently. I have attributes strings of the form
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE

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.