arcgissamples\trackinganalyst\ui\ServerInfoDialog.java—ArcObjects 10.4 Help for Java | ArcGIS for Desktop
Display tracking server layer
arcgissamples\trackinganalyst\ui\ServerInfoDialog.java
/* 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.
* 
*/
package arcgissamples.trackinganalyst.ui;

import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.*;

import com.esri.arcgis.controls.IGlobeHookHelper;

public class ServerInfoDialog extends JDialog {
  JTextField serverTextBox = null;
  JTextField serviceTextBox = null;

  IGlobeHookHelper globeHookHelper = null;

  public ServerInfoDialog(String title, IGlobeHookHelper ghh) {
    super();
    this.globeHookHelper = ghh;
    setTitle(title);
    setSize(250, 75);
    getContentPane().add(createPanel());
    pack();
    setVisible(true);
  }

  private JPanel createPanel() {
    JPanel panel = new JPanel();
    panel.setPreferredSize(new Dimension(250, 75));
    panel.setSize(new Dimension(250, 75));
    panel.setLayout(new GridBagLayout());

    GridBagConstraints serverLabelGBConstraints = new GridBagConstraints();
    serverLabelGBConstraints.gridx = 2;
    serverLabelGBConstraints.gridy = 2;
    serverLabelGBConstraints.insets = new Insets(10, 10, 5, 0);
    serverLabelGBConstraints.weightx = 1.0D;
    serverLabelGBConstraints.weighty = 1.0D;
    serverLabelGBConstraints.fill = GridBagConstraints.HORIZONTAL;
    serverLabelGBConstraints.anchor = GridBagConstraints.NORTHWEST;
    JLabel serverLabel = new JLabel("Server Name: ");
    panel.add(serverLabel, serverLabelGBConstraints);

    GridBagConstraints serverTextBoxGBConstraints = new GridBagConstraints();
    serverTextBoxGBConstraints.gridx = 3;
    serverTextBoxGBConstraints.gridy = 2;
    serverTextBoxGBConstraints.insets = new Insets(10, 0, 5, 5);
    serverTextBoxGBConstraints.weightx = 1.0D;
    serverTextBoxGBConstraints.weighty = 1.0D;
    serverTextBoxGBConstraints.fill = GridBagConstraints.HORIZONTAL;
    serverTextBoxGBConstraints.anchor = GridBagConstraints.NORTHWEST;
    serverTextBox = new JTextField(20);
    panel.add(serverTextBox, serverTextBoxGBConstraints);

    ServerInfoListener listener = new ServerInfoListener(this, globeHookHelper);

    GridBagConstraints okButtonGBConstraints = new GridBagConstraints();
    okButtonGBConstraints.gridx = 2;
    okButtonGBConstraints.gridy = 3;
    okButtonGBConstraints.insets = new Insets(5, 5, 10, 5);
    okButtonGBConstraints.weightx = 1.0D;
    okButtonGBConstraints.weighty = 1.0D;
    okButtonGBConstraints.fill = GridBagConstraints.HORIZONTAL;
    okButtonGBConstraints.anchor = GridBagConstraints.NORTHWEST;

    JButton okButton = new JButton("Connect");
    okButton.setMnemonic(KeyEvent.VK_N);
    okButton.setActionCommand("connect");
    okButton.setEnabled(true);
    okButton.addActionListener(listener);

    panel.add(okButton, okButtonGBConstraints);

    GridBagConstraints cancelButtonGBConstraints = new GridBagConstraints();
    cancelButtonGBConstraints.gridx = 3;
    cancelButtonGBConstraints.gridy = 3;
    cancelButtonGBConstraints.insets = new Insets(5, 5, 10, 5);
    cancelButtonGBConstraints.weightx = 1.0D;
    cancelButtonGBConstraints.weighty = 1.0D;
    cancelButtonGBConstraints.fill = GridBagConstraints.HORIZONTAL;
    cancelButtonGBConstraints.anchor = GridBagConstraints.NORTHWEST;

    JButton cancelButton = new JButton("Cancel");
    cancelButton.setMnemonic(KeyEvent.VK_C);
    cancelButton.setActionCommand("cancel");
    cancelButton.setEnabled(true);
    cancelButton.addActionListener(listener);

    panel.add(cancelButton, cancelButtonGBConstraints);

    return panel;
  }

  public JTextField getServerTextBox() {
    return this.serverTextBox;
  }

  public JTextField getServiceTextBox() {
    return this.serviceTextBox;
  }
}