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

MapBean map;<br />

TOCBean toc;<br />

ToolbarBean toolbar;<br />

JLabel statusLabel;<br />

// Constructor<br />

public MapViewerFrame() {<br />

setTitle("MapViewer");<br />

pageLayout = new PageLayoutBean();<br />

map = new MapBean();<br />

toc = new TOCBean();<br />

toolbar = new ToolbarBean();<br />

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

6. In the MapViewerFrame user interface, the toolbar component will occupy<br />

BorderLayout.NORTH, and the pageLayout component will occupy the<br />

BorderLayout.CENTER position.<br />

The BorderLayout.WEST position will be occupied by both the TOC and map<br />

components. To achieve this, create a new method to build a JPanel containing<br />

the two controls with the desired layout:<br />

// New method to build the left panel<br />

private JPanel buildMapTOCPanel() {<br />

JPanel leftPanel = new JPanel();<br />

JPanel bottomPanel = new JPanel();<br />

leftPanel.setLayout(new BorderLayout());<br />

bottomPanel.setLayout(new BorderLayout());<br />

bottomPanel.setPreferredSize(new Dimension(200,200));<br />

bottomPanel.add(map, BorderLayout.CENTER);<br />

leftPanel.add(toc, BorderLayout.CENTER);<br />

leftPanel.add(bottomPanel, BorderLayout.SOUTH);<br />

return leftPanel;<br />

}<br />

7. In the BorderLayout.SOUTH position of the MapViewerFrame, add a JLabel<br />

to act as a status bar. The buildAndShow() method should look like the<br />

following once you have updated it with all layout locations:<br />

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

JPanel mapTOCPanel = buildMapTOCPanel();<br />

this.getContentPane().add(toolbar, BorderLayout.NORTH);<br />

this.getContentPane().add(pageLayout, BorderLayout.CENTER);<br />

this.getContentPane().add(mapTOCPanel, BorderLayout.WEST);<br />

this.getContentPane().add(statusLabel, BorderLayout.SOUTH);<br />

}<br />

this.setVisible();<br />

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

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

Saved successfully!

Ooh no, something went wrong!