Results 1 to 2 of 2
  1. #1
    rasen58 is offline Member
    Join Date
    Oct 2012
    Rep Power

    Default JLayeredPane isnt displaying

    In my applet, I have a layered pane, but it isnt showing. Can you tell me why?
    Java Code:
    import javax.swing.*;
    import java.awt.*;
    public class birthday extends JApplet
    	JPanel panel;
    	JLayeredPane pane;
    	JLabel background;
    	ImageIcon card;
    	JButton enter;
    	JLabel label;
    	JPasswordField pass;
    	JProgressBar progress;
    	public void init()
    		setLayout(new FlowLayout());
    		setSize(700, 600);
    		pane = new JLayeredPane();
    		pane.setPreferredSize(new Dimension(400, 410));
    		card = new ImageIcon(getClass().getResource("jfdlk.png"));
    		background = new JLabel();
    		//pane.add(background, 1);
    		enter = new JButton("Press Me!");
    		//pane.add(enter, JLayeredPane.DEFAULT_LAYER);
    		pane.add(enter, new Integer(1));
    		JButton t2 = new JButton();
    		pane.add(t2, new Integer(0));
    		//panel = new JPanel();

  2. #2
    rasen58 is offline Member
    Join Date
    Oct 2012
    Rep Power

    Default Re: JLayeredPane isnt displaying

    Never mind I figured it out, there was not layout in the pane, so I had to set the bounds myself. thanks anyway. But I do have a question, why must you put new Integer(x) in pane.add()? Why can't you just put x?
    Last edited by rasen58; 11-01-2012 at 04:24 PM.

Similar Threads

  1. JLayeredPane issues?!
    By seniorstatus in forum AWT / Swing
    Replies: 21
    Last Post: 04-29-2012, 01:47 AM
  2. Replies: 1
    Last Post: 05-30-2011, 09:37 PM
  3. JLayeredPane not displaying components
    By abc in forum AWT / Swing
    Replies: 3
    Last Post: 01-06-2011, 03:40 PM
  4. How to add JScrolPane to a JLayeredPane?
    By chyrl in forum Advanced Java
    Replies: 5
    Last Post: 08-30-2010, 04:28 AM
  5. Replies: 8
    Last Post: 10-29-2009, 10:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts