18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING APPLICATIONS WITH VISUAL JAVABEANS<br />

To compile using the command line, use the “cd” command to change to the<br />

directory containing the MapViewerFrame and MapViewer Java code and give<br />

a command similar to:<br />

To run the Java program, click the Run button in<br />

your IDE or give the following command from<br />

the command line:<br />

java -classpath<br />

\java\<br />

opt\arcgis_visualbeans.jar;<br />

\java\opt\<br />

arcobjects.jar;<br />

\java\<br />

jintegra.jar;. MapViewer<br />

javac -classpath<br />

\java\opt\arcgis_visualbeans.jar;<br />

\java\opt\arcobjects.jar;<br />

\java\jintegra.jar;. *.java<br />

This compiles the Java program and produces a MapViewerFrame.class and a<br />

MapViewer.class file. If you get NoClassDefFoundError, double-check your class<br />

path and make sure it includes all three required JAR files—arcobjects.jar, arcgis_<br />

visualbeans.jar, and jintegra.jar.<br />

4. Launch the MapViewer class and make sure a blank Java frame comes up<br />

before proceeding to the next step.<br />

5. Next, add member variables for the components to be added to the<br />

MapViewerFrame class and create these components in the constructor.<br />

// MapViewerFrame.java<br />

import java.io.IOException;<br />

import javax.swing.JFrame;<br />

// Add new imports for this step:<br />

import javax.swing.JLabel;<br />

import java.awt.BorderLayout;<br />

import java.awt.Dimension;<br />

import javax.swing.JPanel;<br />

import com.esri.arcgis.beans.TOC.TOCBean;<br />

import com.esri.arcgis.beans.map.MapBean;<br />

import com.esri.arcgis.beans.pagelayout.PageLayoutBean;<br />

import com.esri.arcgis.beans.toolbar.ToolbarBean;<br />

308 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong><br />

public class MapViewerFrame extends JFrame {<br />

PageLayoutBean pageLayout;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!