public void actionPerformed(ActionEvent evt) {
    Object src = evt.getSource();

    if (src == btnAdd) {

      LineStyle style = new LineStyle();
      EditorDialog.show(this, new EdgeStyleEditor(style, canvas, true), true);
      if (style.getId() != null) {
        canvas.addEdgeStyle(style);
        jlistModel.addElement(style.getId());
      }
      return;

    } else if (src == btnEdit) {

      int index = jlist.getSelectedIndex();
      if (index == -1) {
        JOptionPane.showMessageDialog(
            this,
            "First select a style from the list",
            "Information",
            JOptionPane.INFORMATION_MESSAGE);
        return;
      }
      LineStyle style = (LineStyle) styles.get(index);
      EditorDialog.show(this, new EdgeStyleEditor(style, canvas, false), true);
      jlistModel.set(index, style.getId());
      canvas.repaint();
      preview.repaint();
      return;

    } else if (src == btnDel) {

      int index = jlist.getSelectedIndex();
      if (index == -1) {
        JOptionPane.showMessageDialog(
            this,
            "First select a style from the list",
            "Information",
            JOptionPane.INFORMATION_MESSAGE);
        return;
      }
      canvas.removeEdgeStyle((LineStyle) styles.get(index));
      jlistModel.remove(index);
      return;
    }
  }
 private void showPreview(LineStyle style) {
   preview.setStyle(style);
 }