This is because the task.get()
is returning a value of type Object
, but you're trying to assign it to v, which is a VideoScrollPane
. You can prevent the error by doing a cast, like so
VideoScrollPane v = (VideoScrollPane)task.get();
Be warned, if task.get()
returns something that isn't a VideoScrollPane
, you'll get a ClassCastException
.
If you want to prevent the problem entirely however, consider fixing the declaration of task
, by including a type for the generic parameter. You could change it to,
Task<VideoScrollPane> task = new Task<VideoScrollPane>() {
This way, task.get()
will now return a VideoScollPane
, and you won't need a cast.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…