public void itemStateChanged(ItemEvent e) {
   ValueLabelItem item = (ValueLabelItem) e.getItem();
   if (e.getStateChange() == ItemEvent.SELECTED) {
     if (e.getSource() == lineThicknessBox) {
       annotation.getBorderStyle().setStrokeWidth((Float) item.getValue());
     } else if (e.getSource() == lineStyleBox) {
       annotation.getBorderStyle().setBorderStyle((Name) item.getValue());
     }
     // save the action state back to the document structure.
     updateCurrentAnnotation();
     currentAnnotationComponent.resetAppearanceShapes();
     currentAnnotationComponent.repaint();
   }
 }
  /**
   * Method that should be called when a new AnnotationComponent is selected by the user The
   * associated object will be stored locally as currentAnnotation Then all of it's properties will
   * be applied to the UI pane For example if the border was red, the color of the background button
   * will be changed to red
   *
   * @param newAnnotation to set and apply to this UI
   */
  public void setAnnotationComponent(AnnotationComponent newAnnotation) {

    if (newAnnotation == null || newAnnotation.getAnnotation() == null) {
      setEnabled(false);
      return;
    }
    // assign the new action instance.
    this.currentAnnotationComponent = newAnnotation;

    // For convenience grab the Annotation object wrapped by the component
    annotation = (InkAnnotation) currentAnnotationComponent.getAnnotation();

    applySelectedValue(lineThicknessBox, annotation.getLineThickness());
    applySelectedValue(lineStyleBox, annotation.getLineStyle());
    colorBorderButton.setBackground(annotation.getColor());

    // disable appearance input if we have a invisible rectangle
    safeEnable(lineThicknessBox, true);
    safeEnable(lineStyleBox, true);
    safeEnable(colorBorderButton, true);
  }
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == colorBorderButton) {
      Color chosenColor =
          JColorChooser.showDialog(
              colorBorderButton,
              messageBundle.getString("viewer.utilityPane.annotation.ink.colorBorderChooserTitle"),
              colorBorderButton.getBackground());
      if (chosenColor != null) {
        // change the colour of the button background
        colorBorderButton.setBackground(chosenColor);
        annotation.setColor(chosenColor);

        // save the action state back to the document structure.
        updateCurrentAnnotation();
        currentAnnotationComponent.resetAppearanceShapes();
        currentAnnotationComponent.repaint();
      }
    }
  }