java - JLayeredPane not showing my custom JPanel -


i'm having trouble getting custom panel show using jlayeredpanel. i'm trying create black rectangle on first layer, , on second layer, have custom jpanel slideshow of images. slideshow not display @ all, works when add frame. thoughts?

code:

import java.awt.color; import java.awt.container; import java.awt.dimension; import java.awt.image; import java.awt.toolkit; import java.util.arraylist;  import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jlayeredpane; import javax.swing.jpanel;  public class gui extends jframe {      private container pane;     private jpanel emptyslideshow;     private jlayeredpane layeredpane;      public gui(){         this.setvisible(true);         dimension screensize = toolkit.getdefaulttoolkit().getscreensize();         this.setbounds(0,0,screensize.width, screensize.height);            //      //set content pane         //      pane = this.getcontentpane(); //get content pane place components         //      pane.setlayout(null); //use absolute positioning (using insets)         //      pane.setbackground(new color(236, 236, 236)); //color background         //         //      //set main menu bar         this.emptyslideshow = new jpanel();         this.emptyslideshow.setbounds(0,0,(int)toolkit.getdefaulttoolkit().getscreensize().getwidth(),250);         this.emptyslideshow.setbackground(new color(0,0,0));              layeredpane = new jlayeredpane();         layeredpane.setlayout(null);         layeredpane.add(this.emptyslideshow,new integer(0));          arraylist<image> slides = new arraylist<image>();          image image1 = new imageicon("pictures/slide1.png").getimage();         slides.add(image1);          image image2 = new imageicon("pictures/slide2.png").getimage();         slides.add(image2);          arraylist<string> transitions = new arraylist<string>();         transitions.add("panlr");         transitions.add("fadeout");           this.add(new slideshow(slides,transitions));         layeredpane.add(new slideshow(slides,transitions),new integer(1));           this.add(layeredpane);        } } 

a guess since don't have of pertinent code -- need specify component's size , position when adding jlayeredpane, , perhaps you're not setting slideshow's size before adding (it's position default 0, 0).

question though: why trying add slideshow jpanel gui twice? once jlayeredpane, , other jframe itself?


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -