Use scene bean
arcgissamples\scenebean\UseSceneBean.java
/* Copyright 2010 ESRI
* 
* All rights reserved under the copyright laws of the United States
* and applicable international laws, treaties, and conventions.
* 
* You may freely redistribute and use this sample code, with or
* without modification, provided you include the original copyright
* notice and use restrictions.
* 
* See the use restrictions.
* 
*/
package arcgissamples.scenebean;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;

import com.esri.arcgis.beans.TOC.TOCBean;
import com.esri.arcgis.beans.scene.SceneBean;
import com.esri.arcgis.beans.toolbar.ToolbarBean;
import com.esri.arcgis.controls.ControlsSceneExpandFOVCommand;
import com.esri.arcgis.controls.ControlsSceneFlyTool;
import com.esri.arcgis.controls.ControlsSceneFullExtentCommand;
import com.esri.arcgis.controls.ControlsSceneNarrowFOVCommand;
import com.esri.arcgis.controls.ControlsSceneNavigateTool;
import com.esri.arcgis.controls.ControlsSceneOpenDocCommand;
import com.esri.arcgis.controls.ControlsScenePanTool;
import com.esri.arcgis.controls.ControlsSceneSelectFeaturesTool;
import com.esri.arcgis.controls.ControlsSceneSelectGraphicsTool;
import com.esri.arcgis.controls.ControlsSceneSetObserverTool;
import com.esri.arcgis.controls.ControlsSceneTargetCenterTool;
import com.esri.arcgis.controls.ControlsSceneTargetZoomTool;
import com.esri.arcgis.controls.ControlsSceneZoomInOutTool;
import com.esri.arcgis.controls.ControlsSceneZoomInTool;
import com.esri.arcgis.controls.ControlsSceneZoomOutTool;
import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.esriLicenseExtensionCode;
import com.esri.arcgis.system.esriLicenseProductCode;
import com.esri.arcgis.system.esriLicenseStatus;

/**
 * Description: Using the Scene, Toc and Toolbar Control Uses the SceneBean to load a SXD file and a ToolbarBean to
 * perform map zoom/pan functions
 */

public class UseSceneBean
{
  SceneBean sceneBean = null;
  ToolbarBean toolbarBean = null;
  TOCBean tocBean = null;
  JFrame frame = null;

  public UseSceneBean()
  {
    initializeArcGISLicenses();
    frame = new JFrame("Java Sample:  SceneControl and ToolbarControl");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    sceneBean = new SceneBean();
    toolbarBean = new ToolbarBean();
    tocBean = new TOCBean();
  }

  public static void main(String[] args) throws java.io.IOException
  {
    EngineInitializer.initializeVisualBeans();
    UseSceneBean arFrame = new UseSceneBean();

    try
    {
      arFrame.display();
    }
    catch (java.io.IOException ioe)
    {
      ioe.printStackTrace();
    }
  }

  void initializeArcGISLicenses() {
    try {
      AoInitialize ao = new AoInitialize();
      
      if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine) 
          == esriLicenseStatus.esriLicenseAvailable)
        ao.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
      else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView) 
          == esriLicenseStatus.esriLicenseAvailable)
        ao.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);
      else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcEditor) 
          == esriLicenseStatus.esriLicenseAvailable)
        ao.initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor);
      else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcInfo) 
          == esriLicenseStatus.esriLicenseAvailable)
        ao.initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo);
      
      ao.checkOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst);
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println(" Program Exit: Unable to check out licenses");
      System.exit(0);
    }
  }

  public void display() throws java.io.IOException
  {

    // set the control size
    sceneBean.setSize(800, 600);
    toolbarBean.setSize(800, 25);
    tocBean.setSize(200, 600);

    frame.getContentPane().add(sceneBean, BorderLayout.CENTER);
    frame.getContentPane().add(toolbarBean, BorderLayout.NORTH);
    frame.getContentPane().add(tocBean, BorderLayout.WEST);

    frame.setSize(new Dimension(800, 700));
    frame.setVisible(true);

    // Set the toolbar buddy to the SceneBean
    toolbarBean.setBuddyControl(sceneBean);
    tocBean.setBuddyControl(sceneBean);

    // Load the pre-built tools
    toolbarBean.addItem(ControlsSceneOpenDocCommand.getClsid(), 0, -1, true, 1, 1); // Open

    toolbarBean.addItem(ControlsSceneNavigateTool.getClsid(), 0, -1, true, 1, 1); // Navigate
    toolbarBean.addItem(ControlsSceneFlyTool.getClsid(), 0, -1, false, 1, 1); // Fly
    toolbarBean.addItem(ControlsSceneZoomInOutTool.getClsid(), 0, -1, false, 1, 1); // ZoomInOut
    toolbarBean.addItem(ControlsSceneZoomInTool.getClsid(), 0, -1, false, 1, 1); // ZoomIn
    toolbarBean.addItem(ControlsSceneZoomOutTool.getClsid(), 0, -1, false, 1, 1); // ZoomOut
    toolbarBean.addItem(ControlsSceneFullExtentCommand.getClsid(), 0, -1, false, 1, 1); // FullExtent
    toolbarBean.addItem(ControlsScenePanTool.getClsid(), 0, -1, false, 1, 1); // Pan

    toolbarBean.addItem(ControlsSceneExpandFOVCommand.getClsid(), 0, -1, true, 1, 1); // ExpandFOV
    toolbarBean.addItem(ControlsSceneNarrowFOVCommand.getClsid(), 0, -1, false, 1, 1); // NarrowFOV

    toolbarBean.addItem(ControlsSceneSelectGraphicsTool.getClsid(), 0, -1, true, 1, 1); // SelectGraphics
    toolbarBean.addItem(ControlsSceneSelectFeaturesTool.getClsid(), 0, -1, false, 1, 1); // SelectFeatures
    toolbarBean.addItem(ControlsSceneSetObserverTool.getClsid(), 0, -1, false, 1, 1); // SetObserver
    toolbarBean.addItem(ControlsSceneTargetCenterTool.getClsid(), 0, -1, false, 1, 1); // TargetCenter
    toolbarBean.addItem(ControlsSceneTargetZoomTool.getClsid(), 0, -1, false, 1, 1); // TargetZoom

  }
}