Close Console window programatically

How can I close the “Console” window that is created, when the 3D Viewer is run and the Image3D universe gets initialized? I am using the 3D Viewer as library to export an image stack, with that in mind the window doesn’t help much the user, thus trying to find a way to close it.

I have tried both through the standard ImageJ macro command close("Console"); and through the ImageJ 1.x WindowManager, which finds no such window/frame. This explains why the macro command didn’t work, but how can I find it, in order to close it?

The Console is a component of the SciJava Swing UI in ImageJ2 (see the Logging page on the wiki), and therefore not specific to the 3D viewer. It gets shown because the 3D viewer produces some log output upon starting.

The following Groovy script (run from the script editor) works for me to hide the console window:

#@ UIService ui

consolePane = ui.getDefaultUI().getConsolePane().getComponent()

component = consolePane
while (!(component instanceof java.awt.Window)) {
	component = component.getParent()

It should be straightforward to translate this to Java code or whatever language you require.