javafxjava-8stagexuggle

javafx: how to close unknown child stages/windows


I use this code to convert a video with xuggler: http://www.jochenhebbrecht.be/site/2010-10-12/java/converting-resizing-videos-in-java-xuggler

The convertion works fine and the line:

reader.addListener(ToolFactory.makeViewer(true));

let me view two windows with video and statistics.The problem is, after converting the windows don't close automatically and I don't know how to do it.

I changed the above line into

IMediaListener imL=ToolFactory.makeViewer(IMediaViewer.Mode.FAST_VIDEO_ONLY,true);
reader.addListener(imL);

and after the while I insert

reader.removeListener(imL);
            reader.close();

But the windows don't disappear after converting/ task finished.So I want to know how I can get access to this windows to achieve a simple stage.close().

EDIT: I'm using Java 8

EDIT2: I now tried

StageHelper.getStages().size(); //-> 1

and

Iterator<Window> windows=Window.impl_getWindows();
String window_String="";
while(windows.hasNext()){
    window_String+=" |-> "+
}  
System.out.println("WINDOWS: ---->"+Window.impl_getWindows());

Both shows that there is just ONE window.It seems, that the windows from "reader.addListener(ToolFactory.makeViewer(true));" are not in the list.


Solution

  • The Problem is that Xuggler uses Swing and not JavaFX so Window.impl_getWindows() and StageHelper.getStages() wont return the windows that are create with ToolFactory.makeViewer(true).

    So the correct way is java.awt.Window.getWindows().