@Override
 public void contentsChanged(ListDataEvent e) {
   // case where the active layer was removed
   if (!layers.contains(activeLayer)) {
     setActiveLayer(null);
   }
   if ((activeLayer == null) && !layers.isEmpty()) {
     setActiveLayer(layers.getLayers()[0]);
   }
   updateGraphicsPanelDrawers();
   getScore().autorescaleScoreAxis();
 }
 /**
  * Method used for serialization
  *
  * @param out
  * @throws IOException
  */
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.writeInt(SAVED_FORMAT_VERSION_NUMBER);
   out.writeInt(trackNumber);
   out.writeObject(backgroundLayer);
   out.writeObject(foregroundLayer);
   // write the number of layers
   if ((layers == null) || layers.isEmpty()) {
     out.writeInt(0);
   } else {
     out.writeInt(layers.size());
     out.writeObject(layers);
     // make sure the active layer is not null
     if (activeLayer == null) {
       setActiveLayer(layers.getLayers()[0]);
     }
     out.writeObject(activeLayer);
   }
   out.writeObject(score);
   // save the height of the track
   out.writeInt(trackPanel.getHeight());
   if (SAVED_FORMAT_VERSION_NUMBER >= 1) {
     out.writeObject(getName());
   }
 }