18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH VISUAL JAVABEANS<br />

In addition, objects from the following libraries will be used:<br />

• Carto • Geometry • Control commands<br />

• Display • SystemUI<br />

In the Java API, their package names are prefixed by ‘com.esri.arcgis’.<br />

To reference the above-mentioned packages, the following JAR files must be<br />

added to your class path:<br />

• arcobjects.jar, located at \<strong>ArcGIS</strong>\java\opt<br />

• arcgis_visualbeans.jar, located at \<strong>ArcGIS</strong>\java\opt<br />

• jintegra.jar, located at \<strong>ArcGIS</strong>\java<br />

IMPLEMENTATION<br />

To implement this scenario follow the steps below. While the scenario specifically<br />

uses the Gulf of St. Lawrence map document installed with the samples, you can<br />

use your own map document instead. The implementation below provides you<br />

with all the code you will need to successfully complete the scenario. It doesn’t<br />

provide step-by-step instructions to develop applications in Java, as it assumes<br />

that you have a working knowledge of the development environment already.<br />

Setting up the development environment<br />

To compile and run applications using the <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> Kit, your<br />

development environment should be set up as described in the Java API section<br />

of Chapter 4, ‘<strong>Developer</strong> environments’.<br />

Use your favorite text editor or IDE to write<br />

your source code.<br />

Building a GUI using the visual components<br />

1. Create a new file called MapViewerFrame.java. The MapViewerFrame class<br />

will provide the GUI and functionality of the map viewer application. Implement<br />

this class as a subclass of javax.swing.JFrame.<br />

// MapViewerFrame.java<br />

import java.io.IOException;<br />

import javax.swing.JFrame;<br />

public class MapViewerFrame extends JFrame {<br />

// Constructor<br />

public MapViewerFrame() {<br />

setTitle("MapViewer");<br />

}<br />

public void buildAndShow() throws IOException {<br />

this.setVisible(true);<br />

}<br />

} // end MapViewerFrame class<br />

2. Create a new file called MapViewer.java. This will provide the main method,<br />

which will construct the MapViewerFrame, give it an initial size, and launch<br />

it:<br />

// MapViewer.java<br />

import java.awt.Dimension;<br />

import java.awt.Toolkit;<br />

306 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!