/* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javafx.scene.media; import javafx.event.Event; import javafx.event.EventTarget; import javafx.event.EventType; /** * An {@link Event} representing the occurrence of an error in handling media. * @since JavaFX 2.0 */ public class MediaErrorEvent extends Event { private static final long serialVersionUID = 20121107L; /** * The only valid event type for the MediaErrorEvent. */ public static final EventType MEDIA_ERROR = new EventType(Event.ANY, "Media Error Event"); /** * The {@link MediaException} which provoked this error event. */ private MediaException error; /** * Construct a new MediaErrorEvent with the specified event * source, target and error. * * @param source the event source which sent the event * @param target the event target to associate with the event * @param error the error which provoked the event * @throws IllegalArgumentException if error is * null. */ MediaErrorEvent(Object source, EventTarget target, MediaException error) { super(source, target, MEDIA_ERROR); if(error == null) { throw new IllegalArgumentException("error == null!"); } this.error = error; } /** * Retrieve the error associated with this event. * * @return The MediaException */ public MediaException getMediaError() { return error; } /** * Retrieve a String representation of the event. */ @Override public String toString() { return super.toString() + ": source " + getSource() + "; target " + getTarget() + "; error " + error; } @Override public MediaErrorEvent copyFor(Object newSource, EventTarget newTarget) { return (MediaErrorEvent) super.copyFor(newSource, newTarget); } @Override public EventType getEventType() { return (EventType) super.getEventType(); } }