arcgissamples\scenario\toc\—ArcObjects 10.4 Help for Java | ArcGIS for Desktop
Engine Viewer
/* Copyright 2015 ESRI
* All rights reserved under the copyright laws of the United States
* and applicable international laws, treaties, and conventions.
* You may freely redistribute and use this sample code, with or
* without modification, provided you include the original copyright
* notice and use restrictions.
* See the use restrictions at <your ArcGIS install location>/DeveloperKit10.4/userestrictions.txt.
 * ArcGIS Engine Developer Sample
 * Application Name:

package arcgissamples.scenario.toc;

/**Label panel used to diplay name of the map frame in the TocControl.
 * Icon and Map title are set using setIcon and setText methods.
 * doLayout method is used to return the preffered width and heigh of the label.

import java.awt.Dimension;

import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class LabelPanel extends JPanel {
  private static final long serialVersionUID = 1L;
  JLabel label = new JLabel();

  public LabelPanel() {
    //Add a label.
    //Sets background color to that of tree control

  /**Sets the icon for this label.
   * @param icon
  public void setIcon(Icon icon) {

  /**Sets the preffered size for the panel.
   * @see javax.swing.JComponent#getPreferredSize()
   * @return java.awt.Dimension
  public Dimension getPreferredSize() {
    return new Dimension(label.getPreferredSize().width,

  /**Sets the text for the label
   * @param stringValue

  public void setText(String stringValue) {

  /** Lays out label based on the prefferred width and height
   *  @see javax.swing.JComponent#doLayout()
  public void doLayout() {
    label.setLocation(0, 0);
    label.setBounds(0, 0, label.getPreferredSize().width,