@Override
  public void actionPerformed(ActionEvent ev) {
    if (ev.getSource() == checkAllButton) {
      for (int i = 0; i < numItems; i++) {
        chooseCB[i].setSelected(true);
      }
    }

    if (ev.getSource() == clearAllButton) {
      for (int i = 0; i < numItems; i++) {
        chooseCB[i].setSelected(false);
      }
    }
    if (ev.getSource() == titleColorButton) {
      Color newColor =
          JColorChooser.showDialog(this, "Select color", titleColorButton.getBackground());
      if (newColor != null) {
        titleColorButton.setBackground(newColor);
      }
    }
    if (ev.getSource() == textColorButton) {
      Color newColor =
          JColorChooser.showDialog(this, "Select color", textColorButton.getBackground());
      if (newColor != null) {
        textColorButton.setBackground(newColor);
      }
    }
    if (ev.getSource() == borderColorButton) {
      Color newColor =
          JColorChooser.showDialog(this, "Select color", borderColorButton.getBackground());
      if (newColor != null) {
        borderColorButton.setBackground(newColor);
      }
    }
  }
  public LayerLegend getLegend() {
    legend.show = showCB.isSelected();
    legend.border = borderCB.isSelected();
    legend.horizontal = horRB.isSelected();

    legend.showTitle = showTitleCB.isSelected();
    legend.border = borderCB.isSelected();
    legend.legendName = titleField.getText();
    legend.legendTitleColor = titleColorButton.getBackground();
    legend.legendTextColor = textColorButton.getBackground();
    legend.legendBorderColor = borderColorButton.getBackground();
    legend.legendFont =
        new Font(
            (String) fontNameCombo.getSelectedItem(),
            styleNumber((String) fontStyleCombo.getSelectedItem()),
            Integer.parseInt((String) fontSizeCombo.getSelectedItem()));

    // legend.layerNumber = Integer.parseInt(layerField.getText());
    try {
      legend.layerNumber = Integer.parseInt(layerField.getText());
    } catch (NumberFormatException ex) {
      JOptionPane.showMessageDialog(
          this,
          iPlug.get("JumpPrinter.Furniture.Message2") + ": " + layerField.getText(),
          iPlug.get("JumpPrinter.Error"),
          JOptionPane.ERROR_MESSAGE);
    }
    for (int i = 0; i < numItems; i++) {
      LegendElement item = legend.legendItems.elementAt(i);
      item.include = chooseCB[i].isSelected();
    }
    // legend.size = Integer.parseInt((String)sizeCombo.getSelectedItem());
    return legend;
  }