/**
   * Initialize the common user interface components.
   *
   * <p>
   */
  protected JButton[] initUI(
      String title, JComponent extraComps, String confirm, String[][] extra, String cancel) {
    JButton[] extraBtns = null;

    /* create dialog body components */
    {
      JPanel body = new JPanel();
      body.setName("MainDialogPanel");

      body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));

      body.add(UIFactory.createPanelLabel("Existing Layouts:"));

      body.add(Box.createRigidArea(new Dimension(0, 4)));

      {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TreeData(), true);
        DefaultTreeModel model = new DefaultTreeModel(root, true);

        JTree tree = new JFancyTree(model);
        pTree = tree;
        tree.setName("DarkTree");

        tree.setCellRenderer(new JLayoutTreeCellRenderer());
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

        {
          JScrollPane scroll =
              UIFactory.createScrollPane(
                  pTree,
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(230, 120),
                  new Dimension(230, 150),
                  null);

          body.add(scroll);
        }
      }

      if (extraComps != null) body.add(extraComps);

      extraBtns = super.initUI(title, body, confirm, null, extra, cancel);
    }

    return extraBtns;
  }
 /**
  * Creates and returns a Container containing the buttons. The buttons are created by calling
  * <code>getButtons</code>.
  */
 protected Container createButtonArea() {
   JPanel bottom = new JPanel();
   Border border = (Border) DefaultLookup.get(optionPane, this, "OptionPane.buttonAreaBorder");
   bottom.setName("OptionPane.buttonArea");
   if (border != null) {
     bottom.setBorder(border);
   }
   bottom.setLayout(
       new ButtonAreaLayout(
           DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", true),
           DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding", 6),
           DefaultLookup.getInt(
               optionPane, this, "OptionPane.buttonOrientation", SwingConstants.CENTER),
           DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast", false)));
   addButtonComponents(bottom, getButtons(), getInitialValueIndex());
   return bottom;
 }
  /**
   * Messaged from installComponents to create a Container containing the body of the message. The
   * icon is the created by calling <code>addIcon</code>.
   */
  protected Container createMessageArea() {
    JPanel top = new JPanel();
    Border topBorder = (Border) DefaultLookup.get(optionPane, this, "OptionPane.messageAreaBorder");
    if (topBorder != null) {
      top.setBorder(topBorder);
    }
    top.setLayout(new BorderLayout());

    /* Fill the body. */
    Container body = new JPanel(new GridBagLayout());
    Container realBody = new JPanel(new BorderLayout());

    body.setName("OptionPane.body");
    realBody.setName("OptionPane.realBody");

    if (getIcon() != null) {
      JPanel sep = new JPanel();
      sep.setName("OptionPane.separator");
      sep.setPreferredSize(new Dimension(15, 1));
      realBody.add(sep, BorderLayout.BEFORE_LINE_BEGINS);
    }
    realBody.add(body, BorderLayout.CENTER);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.gridheight = 1;
    cons.anchor =
        DefaultLookup.getInt(
            optionPane, this, "OptionPane.messageAnchor", GridBagConstraints.CENTER);
    cons.insets = new Insets(0, 0, 3, 0);

    addMessageComponents(body, cons, getMessage(), getMaxCharactersPerLineCount(), false);
    top.add(realBody, BorderLayout.CENTER);

    addIcon(top);
    return top;
  }
  /**
   * Creates the appropriate object to represent <code>msg</code> and places it into <code>container
   * </code>. If <code>msg</code> is an instance of Component, it is added directly, if it is an
   * Icon, a JLabel is created to represent it, otherwise a JLabel is created for the string, if
   * <code>d</code> is an Object[], this method will be recursively invoked for the children. <code>
   * internallyCreated</code> is true if Objc is an instance of Component and was created internally
   * by this method (this is used to correctly set hasCustomComponents only if !internallyCreated).
   */
  protected void addMessageComponents(
      Container container,
      GridBagConstraints cons,
      Object msg,
      int maxll,
      boolean internallyCreated) {
    if (msg == null) {
      return;
    }
    if (msg instanceof Component) {
      // To workaround problem where Gridbad will set child
      // to its minimum size if its preferred size will not fit
      // within allocated cells
      if (msg instanceof JScrollPane || msg instanceof JPanel) {
        cons.fill = GridBagConstraints.BOTH;
        cons.weighty = 1;
      } else {
        cons.fill = GridBagConstraints.HORIZONTAL;
      }
      cons.weightx = 1;

      container.add((Component) msg, cons);
      cons.weightx = 0;
      cons.weighty = 0;
      cons.fill = GridBagConstraints.NONE;
      cons.gridy++;
      if (!internallyCreated) {
        hasCustomComponents = true;
      }

    } else if (msg instanceof Object[]) {
      Object[] msgs = (Object[]) msg;
      for (Object o : msgs) {
        addMessageComponents(container, cons, o, maxll, false);
      }

    } else if (msg instanceof Icon) {
      JLabel label = new JLabel((Icon) msg, SwingConstants.CENTER);
      configureMessageLabel(label);
      addMessageComponents(container, cons, label, maxll, true);

    } else {
      String s = msg.toString();
      int len = s.length();
      if (len <= 0) {
        return;
      }
      int nl;
      int nll = 0;

      if ((nl = s.indexOf(newline)) >= 0) {
        nll = newline.length();
      } else if ((nl = s.indexOf("\r\n")) >= 0) {
        nll = 2;
      } else if ((nl = s.indexOf('\n')) >= 0) {
        nll = 1;
      }
      if (nl >= 0) {
        // break up newlines
        if (nl == 0) {
          JPanel breakPanel =
              new JPanel() {
                public Dimension getPreferredSize() {
                  Font f = getFont();

                  if (f != null) {
                    return new Dimension(1, f.getSize() + 2);
                  }
                  return new Dimension(0, 0);
                }
              };
          breakPanel.setName("OptionPane.break");
          addMessageComponents(container, cons, breakPanel, maxll, true);
        } else {
          addMessageComponents(container, cons, s.substring(0, nl), maxll, false);
        }
        addMessageComponents(container, cons, s.substring(nl + nll), maxll, false);

      } else if (len > maxll) {
        Container c = Box.createVerticalBox();
        c.setName("OptionPane.verticalBox");
        burstStringInto(c, s, maxll);
        addMessageComponents(container, cons, c, maxll, true);

      } else {
        JLabel label;
        label = new JLabel(s, JLabel.LEADING);
        label.setName("OptionPane.label");
        configureMessageLabel(label);
        addMessageComponents(container, cons, label, maxll, true);
      }
    }
  }
  /** Construct a new dialog. */
  public JExecDetailsDialog() {
    super("Execution Details");

    /* create dialog body components */
    {
      JPanel body = new JPanel();
      body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));

      {
        JPanel panel = new JPanel();
        panel.setName("MainDialogPanel");
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        /* working directory */
        {
          panel.add(UIFactory.createPanelLabel("Working Directory:"));

          panel.add(Box.createRigidArea(new Dimension(0, 4)));

          JTextField field = UIFactory.createTextField(null, 100, JLabel.LEFT);
          pWorkingDirField = field;

          panel.add(field);
        }

        body.add(panel);
      }

      {
        JPanel panel = new JPanel();
        panel.setName("HorizontalBar");

        Dimension size = new Dimension(100, 7);
        panel.setPreferredSize(size);
        panel.setMinimumSize(size);
        panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 7));

        body.add(panel);
      }

      /* command line */
      JPanel above = new JPanel();
      {
        above.setName("MainDialogPanel");
        above.setLayout(new BoxLayout(above, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pCommandLineLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          above.add(hbox);
        }

        above.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          JTextArea area = new JTextArea(null, 5, 70);
          pCommandLineArea = area;

          area.setName("CodeTextArea");
          area.setLineWrap(true);
          area.setWrapStyleWord(true);
          area.setEditable(false);
        }

        {
          JScrollPane scroll =
              UIFactory.createScrollPane(
                  pCommandLineArea,
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 27),
                  null,
                  null);

          above.add(scroll);
        }
      }

      /* environment */
      JPanel below = new JPanel();
      {
        below.setName("MainDialogPanel");
        below.setLayout(new BoxLayout(below, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pEnvLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          below.add(hbox);
        }

        below.add(Box.createRigidArea(new Dimension(0, 4)));

        Component comps[] = UIFactory.createTitledPanels();
        {
          JPanel tpanel = (JPanel) comps[0];
          JPanel vpanel = (JPanel) comps[1];

          tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0)));
          vpanel.add(Box.createHorizontalGlue());
        }

        {
          pEnvScroll =
              UIFactory.createScrollPane(
                  comps[2],
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 50),
                  new Dimension(100, 300),
                  null);

          below.add(pEnvScroll);
        }
      }

      {
        JVertSplitPanel split = new JVertSplitPanel(above, below);
        split.setResizeWeight(0.0);
        split.setAlignmentX(0.5f);

        body.add(split);
      }

      super.initUI("X", body, null, null, null, "Close", null);
    }
  }