Listing 1 {CODE} AcetateLayer acetateLayer = new AcetateLayer(new graphicsLayer()); acetateLayer.setName("My Graphics Layer"); aMap.add(acetateLayer); LayerEvent event = new LayerEvent(acetateLayer.getLayer(), LayerEvent.ADD); aMap.getLayerset().processLayerEvent(event); {/CODE} LISTING 2: Retrieve the current Toc component {CODE} Component component = aToc.getViewport().getView(); {/CODE} LISTING 3 {CODE} JPanel jpp = new JPanel(); jpp.setLayout(new BorderLayout()); jpp.add(component,BorderLayout.NORTH); {/CODE} LISTING 4 {CODE} public class dynamic_layer extends JPanel { customMouseAdapter myMouseAdapter = new customMouseAdapter(); com.esri.mo.ui.bean.AcetateLayer m_acetate; com.esri.mo.ui.bean.Map m_map; public dynamic_layer(com.esri.mo.ui.bean.AcetateLayer layer, com.esri.mo.ui.bean.Map map) { m_acetate = layer; m_map = map; /* Set the layout manager for the JPanel. FlowLayout fl = new FlowLayout(); this.setLayout(fl); fl.setAlignment(FlowLayout.LEFT); fl.setHgap(3); fl.setVgap(1); //Add a check box with an ActionListener to set the visibility of the AcetateLayer final JCheckBox jcb = new JCheckBox(); jcb.setSelected(true); jcb.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ if (jcb.isSelected()) { m_map.add(m_acetate); m_map.redraw(); } else { m_map.remove((Component) m_acetate); // After removing the AcetateLayer, the Map needs to be repainted m_map.repaint(); m_map.redraw(); } } }); // Construct the legend label JTextField jtf = new JTextField("My Dynamic Layer"); jtf.setEditable(false); // Add the components, set the color and size of the legend this.add(jcb); this.add(jtf); setBackground(Color.lightGray); setPreferredSize(new Dimension(140, 50)); /* Add a MouseListener to listen for mouse interaction with the legend JPanel. * For example, selecting a legend to make it active. */ addMouseListener(myMouseAdapter); } public void paintComponent(Graphics g){ super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; // Add the symbol swatch to the legend component java.awt.geom.Area e = new java.awt.geom.Area(new Rectangle2D.Double(17,25,15,15)); g2d.setColor(new Color(0,20,250)); g2d.fill(e); g2d.setColor(new Color(0, 0, 0)); g2d.draw(e); } } 4) Once the new JPanel for the dynamic layer is created, add it to the "parent" JPanel, then associate the "parent" JPanel with the existing Toc. {CODE} dynamic_layer dyn_layer = new dynamic_layer(myAcetateLayer, map1); jpp.add(dyn_layer, BorderLayout.CENTER); aToc.setViewportView(jpp); {/CODE}