Layered Panel demo 2 : LayeredPane « Swing JFC « Java






Layered Panel demo 2

Layered Panel demo 2
 
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class LayeredPaneDemo extends JFrame {
  public LayeredPaneDemo() {
    super("");
    setSize(570, 400);
    getContentPane().setBackground(new Color(244, 232, 152));

    getLayeredPane().setOpaque(true);

    JButton[] frames = new JButton[5];
    for (int i = 0; i < 5; i++) {
      frames[i] = new JButton("InnerFrame " + i);
      frames[i].setBounds(50 + i * 20, 50 + i * 20, 200, 200);
      getLayeredPane().add(frames[i]);
    }

    WindowListener l = new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    };

    addWindowListener(l);
    setVisible(true);
  }

  public static void main(String[] args) {
    new LayeredPaneDemo();
  }
}

           
         
  








Related examples in the same category

1.A demonstration of the JLayeredPane classA demonstration of the JLayeredPane class
2.JLayeredPane SampleJLayeredPane Sample
3.Implement buttons at different layers
4.Layered Pane DemoLayered Pane Demo
5.LayeredPane Demo 2: Custom MDILayeredPane Demo 2: Custom MDI
6.LayeredPane Demo 3: Custom MDILayeredPane Demo 3: Custom MDI
7.LayeredPane Demo 4: Custom MDILayeredPane Demo 4: Custom MDI