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