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

Customizing the ToolbarBean<br />

In addition to adding <strong>ArcGIS</strong> <strong>Engine</strong> commands and tools to the ToolbarBean<br />

using addItem() as shown above, you can also add them by customizing the<br />

ToolbarBean using the Customize dialog box. To do this, you will place the<br />

Toolbar component in customize mode and display the Customize dialog box.<br />

1. Add the following imports to MapViewerFrame.Java:<br />

Note that only tools and commands that are<br />

registered on the system as COM components<br />

can be added to the toolbar using the customize<br />

dialog box. Java commands and tools (like the<br />

one built in the previous step) do not appear in<br />

the Customize dialog box, as they are not<br />

registered as COM components in the system<br />

registry.<br />

import javax.swing.JCheckBox;<br />

import java.awt.event.ActionEvent;<br />

import java.awt.event.ActionListener;<br />

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

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

import<br />

com.esri.arcgis.beans.toolbar.ICustomizeDialogEventsOnCloseDialogEvent;<br />

import<br />

com.esri.arcgis.beans.toolbar.ICustomizeDialogEventsOnStartDialogEvent;<br />

2. Add the class members.<br />

. . .<br />

public class MapViewerFrame extends JFrame {<br />

JCheckBox customizeCB; // JCheckbox to control toolbar customization<br />

CustomizeDialog customizeDialog; // The Customize dialog box used by<br />

// the ToolbarBean constructor.<br />

3. Create a new method “createCustomizeDialog()” to instantiate the Customize<br />

dialog box. Add the following code:<br />

private void createCustomizeDialog() throws IOException {<br />

customizeDialog = new CustomizeDialog();<br />

customizeDialog.setDialogTitle("Customize Toolbar Items");<br />

customizeDialog.setShowAddFromFile(true);<br />

// Set the toolbar that the new items will be added to.<br />

customizeDialog.setDoubleClickDestination(toolbar);<br />

}<br />

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