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 satya369@usa.net

Thanks in advance !
-satya
dillikarsAsked:
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.

expertmbCommented:
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++){
                  if(i<layerNames.length){
                    button = new JButton("Add to"+layerNames[i]);
                    button.setActionCommand(layerNames[i]);      
                  }else{
                    button = new JButton("Clear the Frames");      
                    button.setActionCommand("Clear");      
                  //  button.setForeGround(Color.red);      
                  }
            button.addActionListener(this)      ;
            panel.add(button);
      }
      getContentPane().add(panel,BorderLayout.SOUTH);
      //this.add(panel,BorderLayout.SOUTH);
            
      layeredPane = getLayeredPane();

      addWindowListener(new WindowEventHandler());
      setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      setSize(500,500);
      show();
      }
      
      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])      {
                  addInternalFrame(0);
            }
            if(tempButton.getActionCommand() == layerNames[1])      {
                  addInternalFrame(1);
            }
            if(tempButton.getActionCommand() == layerNames[2])      {
                  addInternalFrame(2);
            }
            if(tempButton.getActionCommand() == layerNames[3])      {
                  addInternalFrame(3);
            }
            if(tempButton.getActionCommand() == layerNames[4])      {
                  addInternalFrame(4);
            }
            
            /*if(tempButton.getActionCommand() == "Clear"){
                  for(Enumeration enum = framesVector.elements();enum.hasMoreElements();){
                        (enum.nextElement()).dispose();
                  }
            framecount = 0;
            }*/
      }      

      public void addInternalFrame(int index){

            JInternalFrame iFrame = new JInternalFrame("In" + layerNames[index],true,true,true,true) ;
            
            framesVector.addElement(iFrame);
            
            iFrame.setLocation(xOffset*(framecount),yOffset*(framecount++));

            iFrame.setSize(200,200);
            iFrame.setDefaultCloseOperation(iFrame.DO_NOTHING_ON_CLOSE);
      
            layeredPane.add(iFrame,layerConstants[index]);

      }

      class WindowEventHandler extends WindowAdapter{

            public void windowClosing(WindowEvent e){
                  System.exit(0);
            }
      }

}


good luck


mb...





0

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
Hardware

From novice to tech pro — start learning today.