Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Transparent Jpanel Problem (JAVA SWING)  RSS feed

 
Deboner Dulos
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to repaint the JPanel with 0% tranparency. But once i clicked the button with action listener with removeAll() method and repaint the Jpanel i got problem with the output.. i got glitches inside the JPanel. Where instead of clearing the jpanel it displays an image from the previous output. Pleas help me with this guys... heres my code.


 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deboner and welcome to the Ranch! After adding/removing components to/from a container in an already displayed Swing GUI, you need to revalidate() the container.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, in the initial setup, all components should be added before, not after, the GUI is made visible.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


If you want full transparency then don't set the background of the panel.

All you need to do is use:




Read Backgrounds With Transparency to understand why using a transparent background causes problems.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!