The Toolbar bean is represented by the IlvJMapsManagerViewControlBar class. This is
a subclass of the framework class IlvJManagerViewControlBar.
An example of the Toolbar is shown in Toolbar .
![toolbar.png](../usrprgmaps/_media/toolbar_default.png)
Toolbar
Including the bean in an application
To include the Toolbar bean in your
application, write the following lines of code:
PropertyDescriptor brightness = new PropertyDescriptor("brightness", IlvRasterStyle.class); ... brightness.setPropertyEditorClass(IlvPercentPropertyEditor.class); IlvJMapsManagerViewControlBar toolbar = new IlvJMapsManagerViewControlBar(); toolbar.setView(view);
Adding the bean to a Swing container
These lines create a standard Rogue Wave®
JViews interactor toolbar that you need to integrate into your
Swing GUI:
panel.add(toolbar, BorderLayout.NORTH);
Customizing the toolbar
For JViews Maps use,
you may want to add more interactors or buttons to this toolbar.
Replacing an interactor
You can replace standard interactors with better-tailored
interactors, such as the IlvMapZoomInteractor, with lines of code
such as:
IlvMapZoomInteractor zi = new IlvMapZoomInteractor(); // chose the way the rectangle is drawn when rotation exists zi.setRotationAllowed(true); // when zoom is selected, it stays, contrary to default JViews. zi.setPermanent(true); //to change from default zoom interactor toolbar.setZoomViewInteractor(zi);
Adding a new interactor
You may want to add a completely new
interactor:
IlvManagerViewInteractor interactor = …; JToggleButton interactorButton = new JToggleButton(interactorIcon);
You have to add a listener to set or pop
this interactor when the toggle button is selected:
interactorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(interactorButton.isSelected()){ // set the interactor view.setInteractor(interactor); // and make sure the view has focus, in case the interactor manages keyboard accelerators view.requestFocus(); } else if (view.getInteractor()==interactor){ // pop the interactor view.popInteractor(); } } });
You also need to pop this interactor
when another one is selected:
InteractorListener interactorListener = new InteractorListener() { public void interactorChanged(InteractorChangedEvent event) { boolean isMyInteractor = (event.getNewValue() == interactor); if (interactorButton.isSelected() != isMyInteractor) { interactorButton.setSelected(isMyInteractor); } } }; view.addInteractorListener(interactorListener);
Then, you can add the interactor button
to the toolbar:
toolbar.add(interactorButton);