Regarding JLayeredPane demo ?

I need any demo program using JLayeredPane  .It should demostrate all the features of the it including  managing layered frames .

pls forward it u got any to

Thanks in advance !
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hi ,

 here is the demo of JLayeredPane just compile and run it

//Demonstrates the swing layered panes .
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JInternalFrame;

public class TJLayeredPane extends JFrame implements ActionListener{
      JButton button;
      JInternalFrame             frame1;
      JLayeredPane layeredPane;
      JFrame frame = new JFrame();
      static int framecount = 0;
      static final int xOffset = 25;
      static final int yOffset = 25;
      int numFrames = 1;

      Integer[] layerConstants = {JLayeredPane.DEFAULT_LAYER,JLayeredPane.PALETTE_LAYER,JLayeredPane.MODAL_LAYER,JLayeredPane.POPUP_LAYER,JLayeredPane.DRAG_LAYER};
      String[] layerNames = {"Default layer","Palette layer","Modale layer","Popup Layer","Drag Layer"};

      Vector  framesVector = new Vector();

      public TJLayeredPane(){
            super("LayeredPane Demo");

            JPanel panel = new JPanel(new GridLayout(3,3));
            panel.setBorder(BorderFactory.createTitledBorder("Click specified button"));
            for(int i = 0; i < layerNames.length+1;i++){
                    button = new JButton("Add to"+layerNames[i]);
                    button = new JButton("Clear the Frames");      
                  //  button.setForeGround(;      
            button.addActionListener(this)      ;
      layeredPane = getLayeredPane();

      addWindowListener(new WindowEventHandler());
      public static void main(String args[]){

            TJLayeredPane frame =  new TJLayeredPane();

      public void actionPerformed(ActionEvent e){
            JButton tempButton = (JButton)e.getSource();

            if(tempButton.getActionCommand() == layerNames[0])      {
            if(tempButton.getActionCommand() == layerNames[1])      {
            if(tempButton.getActionCommand() == layerNames[2])      {
            if(tempButton.getActionCommand() == layerNames[3])      {
            if(tempButton.getActionCommand() == layerNames[4])      {
            /*if(tempButton.getActionCommand() == "Clear"){
                  for(Enumeration enum = framesVector.elements();enum.hasMoreElements();){
            framecount = 0;

      public void addInternalFrame(int index){

            JInternalFrame iFrame = new JInternalFrame("In" + layerNames[index],true,true,true,true) ;



      class WindowEventHandler extends WindowAdapter{

            public void windowClosing(WindowEvent e){


good luck



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.