java - Remove transparent JPanel from JPanel -


I want to change one panel from the other (all of them have a transparent section) the code is as follows:

  import java.awt.Color; Import java.awt.EventQueue; Import java.awt.Graphics; Import java.awt.GridLayout; Import java.awt.Image; Import java.util.Timer; Import java.util.TimerTask; Import javax.swing.ImageIcon; Import javax.swing.JFrame; Import javax.swing.JLabel; Import javax.swing.JPanel; Public category photoframe extension of GeFrame {public class} PhotosDisplayPanel JPanel {Personal Static Final Long Serial VERSIONUID = 1L; Private string [] imgsLink = null; Private long delays = 1000; Private long period = 1000; Private In CurIdx = 0; Private PhotoDisplayPanel currentPhoto = null; Public photospace (string [] image link) {super (); This.imgsLink = imgsLink; SetBackground (new color (0, 0, 0, 0)); Setout (new grid layout (1, 1)); CurrentPhoto = New PhotoDisplayPlanel (IMGS Links [Curds]); Adding (currentPhoto); } Public Zero Starter () {if (imgsLink == zero) {Return; } CurIdx = -1; Timer timer = new timer (); Timer Scheduling (New Timer Task) {@ Override Public Void Run () {curIdx ++; If (curIdx> = imgsLink.length) {curIdx = 0;} displayNextImage ();}}, delay, duration); } Protected Zero Exposure Next Image () {If (current photo! = Null) {delete (current photo); } Modify (); Repaint (); CurrentPhoto = New PhotoDisplayPlanel (IMGS Links [Curds]); Adding (currentPhoto); Re-verified (); Repaint (); } @ Override Protected Zero Paint Comonant (Graphics G) {SuperPaintConant (G); }} Public Square PhotoDisplayPanel JPanel {Personal Stable Final Long Serial VersionUID = 1L; Private string impulse; Public Photodispannel (string impalque) {super (); This.imgLink = imgLink; } @ Override Protected Zero PaintCompany (Graphics G) {If (Eaglink! = Null & amp;! IMGLink.exls ("")) {System.out.println ("Create Image"); // IA Amplitude of the panel pWidth = getWidth (); Int pHeight = getHeight (); G.setColor (new color (255, 0, 0, 50)); G.fillRect (0, 0, pWidth, pHeight); Image IMG = New Image (IMGLink) .getImage (); // Calculate the conditions and dimensions imgWidth = img.getWidth (this); Int imgHeight = img.getHeight (this); Int iwidth = 0; Int iheight = 0; If (IMGWith / IMGHET> PWD / PHEIT) {iwidth = pWidth; Iheight = IMGHight * PWD / IMGWath; } And {iheight = pHight; Iwidth = imgWidth * pHeight / imgHeight; } Int ix = (pWidth - iwidth) / 2; Int ii = (pHight - iHit) / 2; // fill out the images on the panel g.drawImage (IMG, ix, IE, IVW, iheight, this); } Other {SuperpintConator (G); }}} Private static last long serial VERSIONUID = 1 L; Private static final difference default Width = 650; Private stable final interval Green = 400; Private int width = defaultweut; Private Initiative = DefaultHigh; Private PhotoDeskPanel Photo Panel; // View panel which displays the private string to // input and output [] imgsLink; Public photoframe () {start (); ImgsLink = New string [] {"background.png", "screenshot.jpg"}; CreateControls (); } Private zero control () {setLayout (new grid layout (0, 1)); PhotoPanel = New PhotoDeskPanel (IMGS Link); Add (photoPanel); PhotoPanel.start (); } Private Zero Starter () {setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); SetSize (width, height); SetTitle ("PhotosFrame"); SetAlwaysOnTop (wrong); SetBackground (Color.CYAN); Setout (new grid layout (1, 1)); SetContentPane (new JLabel (new image ("blue_sunset.jpg"))); } Public static Zero main (string [] algens) {EventQueue.invokeLater (new runnab) (public run to zero) {new photoframe (.) SetVisible (true);}}); }}   

In which, the current photo is a panel with a transparent background. However, the image of the old panel is not completely clear, I can see a new under the old one. Is there any way to clean the image of the old panel widely? Thank you

However, the image of the old panel is not completely clean,

Check out the possible reasons and some solutions.

Originally using a transparent background, the swing does not know that the background needs to be redesigned so that you need to rebuild.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -