/** Create and initialise the user interface. */
  protected void initUI() {
    //  Choices for label positioning.
    xEdge.addItem("BOTTOM");
    xEdge.addItem("TOP");
    yEdge.addItem("LEFT");
    yEdge.addItem("RIGHT");

    //  Act on request to display/remove a label.
    xShowLabel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchXShown();
          }
        });
    yShowLabel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchYShown();
          }
        });

    //  Set ColourIcon of colour button.
    colourButton.setIcon(colourIcon);
    colourButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            chooseColour();
          }
        });

    //  New labels are copied to AstAxisLabel.... Need to intercept
    //  keystrokes.
    Document doc = xTextField.getDocument();
    doc.addDocumentListener(
        new DocumentListener() {
          public void changedUpdate(DocumentEvent e) {
            matchXText();
          }

          public void insertUpdate(DocumentEvent e) {
            matchXText();
          }

          public void removeUpdate(DocumentEvent e) {
            matchXText();
          }
        });
    doc = yTextField.getDocument();
    doc.addDocumentListener(
        new DocumentListener() {
          public void changedUpdate(DocumentEvent e) {
            matchYText();
          }

          public void insertUpdate(DocumentEvent e) {
            matchYText();
          }

          public void removeUpdate(DocumentEvent e) {
            matchYText();
          }
        });

    //  New gaps.
    xGapSpinner = new ScientificSpinner(xSpinnerModel);
    xGapSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            matchXGap();
          }
        });

    yGapSpinner = new ScientificSpinner(ySpinnerModel);
    yGapSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            matchYGap();
          }
        });

    //  Edge selection.
    xEdge.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchXEdge();
          }
        });
    yEdge.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchYEdge();
          }
        });

    //  Units display.
    xUnits.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchXUnits();
          }
        });
    yUnits.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchYUnits();
          }
        });

    //  Add components.
    GridBagLayouter layouter = Utilities.getGridBagLayouter(this);

    layouter.add("Show X:", false);
    layouter.add(xShowLabel, true);

    layouter.add("X label:", false);
    layouter.add(xTextField, true);

    layouter.add("Show Y:", false);
    layouter.add(yShowLabel, true);

    layouter.add("Y label:", false);
    layouter.add(yTextField, true);

    addFontControls(layouter);

    layouter.add("Colour:", false);
    layouter.add(colourButton, false);
    layouter.eatLine();

    layouter.add("X gap:", false);
    layouter.add(xGapSpinner, false);
    layouter.eatLine();

    layouter.add("Y gap:", false);
    layouter.add(yGapSpinner, false);
    layouter.eatLine();

    layouter.add("X edge:", false);
    layouter.add(xEdge, false);
    layouter.eatLine();

    layouter.add("Y edge:", false);
    layouter.add(yEdge, false);
    layouter.eatLine();

    layouter.add("X units:", false);
    layouter.add(xUnits, true);

    layouter.add("Y units:", false);
    layouter.add(yUnits, true);

    layouter.eatSpare();

    //  Set tooltips.
    colourButton.setToolTipText("Select a colour");
    xTextField.setToolTipText("Type in the X axis label");
    yTextField.setToolTipText("Type in the Y axis label");
    xGapSpinner.setToolTipText("Set the gap between label and axis");
    yGapSpinner.setToolTipText("Set the gap between label and axis");
    xEdge.setToolTipText("Set edge for displaying label");
    yEdge.setToolTipText("Set edge for displaying label");
    xUnits.setToolTipText("Append any X axis units to label");
    xUnits.setToolTipText("Append any Y axis units to label");
  }