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 />

6. In the addEventListeners() method, add an event listener to the pageLayout<br />

component for the onMouseDown event, as an anonymous inner class, using<br />

IPageLayoutControlEventsAdapter:<br />

pageLayout.addIPageLayoutControlEventsListener(<br />

new IPageLayoutControlEventsAdapter(){<br />

public void onPageLayoutReplaced(<br />

IPageLayoutControlEventsOnPageLayoutReplacedEvent evt)<br />

throws IOException{<br />

map.loadMxFile(pageLayout.getDocumentFilename(), null, null);<br />

map.setExtent(map.getFullExtent());<br />

}<br />

public void onMouseDown(IPageLayoutControlEventsOnMouseDownEvent<br />

evt) throws IOException {<br />

// If Right mouse button(2) is pressed, display the popup menu.<br />

if(evt.getButton() == 2)<br />

popupMenu.popupMenu(evt.getX(), evt.getY(), pageLayout.getHWnd());<br />

}<br />

});<br />

7. Run the application.<br />

Right-click the pageLayout component to display the popup menu, and navigate<br />

around the page layout.<br />

Controlling label editing in the TOCBean<br />

By default, the TOCBean allows users to automatically toggle the visibility of<br />

layers and to change map and layer names as they appear in the table of contents.<br />

You will add code to prevent users from editing a name and replacing it with an<br />

empty string.<br />

1. Add the following imports to MapViewerFrame.java for classes used in this<br />

step:<br />

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

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

Chapter 6 • <strong>Developer</strong> scenarios • 315

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

Saved successfully!

Ooh no, something went wrong!