Results 1 to 6 of 6

Thread: Use of JLayeredPane class

  1. #1
    Join Date
    Dec 2009
    Posts
    68

    Use of JLayeredPane class

    Hi friend,

    I am new to the java programming. I need your help to know about the one of the class of java and which is 'JLayeredPane class'. I have to make use of this java class in my java project. But I don't know anything about this JLayeredPane class of java. I also want to know about it's methods. If you have sound knowledge about JLayeredPane class of java, then please try to share it wit me. Your help would be greatly appreciable.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Use of JLayeredPane class

    A JLayeredPane adds depth to a JFC/Swing container, allowing components to overlap each other when needed. An Integer object specifies each component's depth in the container, where higher-numbered components sit "on top" of other components. For convenience, JLayeredPane divides the depth-range into several different layers. Putting a component into one of those layers makes it easy to ensure that components overlap properly, without having to worry about specifying numbers for specific depths.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Use of JLayeredPane class

    Hi,

    I suggest you to refer follwing example of java which will demonstrate you the use of JLayeredPane class:
    Code:
    import javax.swing.JLayeredPane;
    
    public class JLayeredPaneDM {
      public static void main(String argbs[]) {
        JFrame f06 = new JFrame("Sample");
        f06.setDef06aultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JLayeredPane desktop01 = new JDesktopPane();
        desktop01.setOpaque(f06alse);
        desktop01.add(new Self06InternalFrame("1"), JLayeredPane.POPUP_LAYER);
        desktop01.add(new Self06InternalFrame("2"), JLayeredPane.DEFAULT_LAYER);
        desktop01.add(new Self06InternalFrame("3"), JLayeredPane.PALETTE_LAYER);    
        
        f06.add(desktop01, BorderLayout.CENTER);
        f06.setSize(300, 200);
        f06.setVisible(true);
      }}
    class Self06InternalFrame extends JInternalFrame {
      public Self06InternalFrame(String s1) {
        getContentPane().add(new JLabel(s1), BorderLayout.CENTER);
        setBounds(60, 60, 100, 100);
        setResizable(true);
        setClosable(true);
        setTitle(s1);
        setVisible(true);
        setMaximizable(true);
        setIconif06iable(true);  
    }
    }

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Use of JLayeredPane class

    Hello friend,

    To use the properties of JLayeredPane class, for that you should be aware about the following it's methods:
    1. setPosition(Component cp, int ComponentPosition)
    2. setLayer(Component cp, int layer1, int ComponentPosition)
    3. setLayer(Component cp, int layer1)
    4. remove(int index1)
    5. putLayer(JComponent cp, int layer1)
    6. insertIndexForLayer(int layer1, int ComponentPosition)

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Use of JLayeredPane class

    Hi friend,

    Following example will show you how to add button using the JLayeredPane class:
    Code:
    import javax.swing.JLayeredPane;
    
    public class SimpleLayersDT extends JFrame {
      public SimpleLayersDT() {
        super("LayeredPane Demonstration");
        setSize(400, 150);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    
        JLayeredPane lp01 = getLayeredPane();
    
         JButton top01 = new JButton();
        top01.setBackground(Color.white);
        top01.setBounds(30, 30, 50, 50);
        JButton middle01 = new JButton();
        middle01.setBackground(Color.gray);
        middle01.setBounds(30, 30, 50, 50);
       
        lp01.add(middle01, new Integer(2));
        lp01.add(top01, new Integer(3));
        lp01.add(bottom, new Integer(1));
      }
    
      public static void main(String[] args) {
        SimpleLayersDT sl1 = new SimpleLayersDT();
        sl1.setVisible(true);
      }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: Use of JLayeredPane class

    I suggest you to go through the following nested classes of the JLayeredPane class of java:
    1. JLayeredPane.AccessibleJLayeredPane
    2. Component.BltBufferStrategy
    3. JComponent.AccessibleJComponent
    4. Component.FlipBufferStrategy
    5. Container.AccessibleAWTContainer

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. What is the difference between Local class and global class in C++?
    By Dëfrim in forum Software Development
    Replies: 4
    Last Post: 03-01-2011, 10:44 PM
  3. Replies: 5
    Last Post: 12-02-2010, 06:23 PM
  4. Ultra solid drives:Imation M-Class and S-Class
    By Regina in forum Portable Devices
    Replies: 1
    Last Post: 03-04-2009, 10:34 AM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,897,757.28732 seconds with 17 queries