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

3. Construct the popupMenu object in a try/catch block:<br />

// Constructor<br />

public MapViewerFrame(){<br />

setTitle( "MapViewer" );<br />

setDefaultCloseOperation(EXIT_ON_CLOSE);<br />

pageLayout = new PageLayoutBean();<br />

map = new MapBean();<br />

toc = new TOCBean();<br />

toolbar = new ToolbarBean();<br />

try {<br />

popupMenu = new ToolbarMenu();<br />

} catch (IOException e) {<br />

e.printStackTrace();<br />

}<br />

statusLabel = new JLabel( " " );<br />

}<br />

4. Add prebuilt commands from the com.esri.arcgis.controlcommands package to<br />

the popupMenu component, before adding generic commands in the<br />

buildAndShow() method:<br />

// Add popup menu items.<br />

popupMenu.addItem( new ControlsPageZoomInFixedCommand(), 0, -1,<br />

false, esriCommandStyles.esriCommandStyleIconAndText );<br />

popupMenu.addItem( new ControlsPageZoomOutFixedCommand(), 0, -1,<br />

false, esriCommandStyles.esriCommandStyleIconAndText );<br />

popupMenu.addItem( new ControlsPageZoomWholePageCommand(), 0, -1,<br />

false, esriCommandStyles.esriCommandStyleIconAndText );<br />

popupMenu.addItem( new ControlsPageZoomPageToLastExtentBackCommand(), 0, -1,<br />

false, esriCommandStyles.esriCommandStyleIconAndText );<br />

popupMenu.addItem( new ControlsPageZoomPageToLastExtentForwardCommand(),<br />

0, -1, false, esriCommandStyles.esriCommandStyleIconAndText );<br />

// Add generic commands to the toolbar.<br />

. . .<br />

5. Associate the popupMenu with the pageLayout component, along with the<br />

code that sets up the buddy controls, in the buildAndShow() method:<br />

// Set buddy controls to wire up the TOC and ToolbarBean<br />

// with the pageLayout object.<br />

toc.setBuddyControl(pageLayout);<br />

toolbar.setBuddyControl(pageLayout);<br />

popupMenu.setHook(pageLayout);<br />

}<br />

setVisible(true);<br />

314 • <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!