Created
February 26, 2018 22:39
-
-
Save ctrueden/29355778db5343b08266dba8d456a790 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Component; | |
import java.awt.Window; | |
import javax.swing.SwingUtilities; | |
import net.imagej.ImageJ; | |
import org.scijava.command.Command; | |
import org.scijava.plugin.Parameter; | |
import org.scijava.ui.UIService; | |
import org.scijava.ui.console.ConsolePane; | |
/** | |
* An illustration of how to access the SciJava Console window. | |
* <p> | |
* Assumes a Swing UI is active on the classpath. | |
* </p> | |
*/ | |
public class ConsoleManipulator implements Command { | |
@Parameter | |
private UIService uiService; | |
@Override | |
public void run() { | |
final ConsolePane<?> consolePane = uiService.getDefaultUI().getConsolePane(); | |
final Object component = consolePane.getComponent(); | |
if (component instanceof Component) { | |
final Window window = SwingUtilities.getWindowAncestor((Component) component); | |
window.setBounds(300, 300, 500, 300); | |
} | |
} | |
public static void main(final String... args) throws Exception { | |
// Launch ImageJ as usual. | |
final ImageJ ij = new ImageJ(); | |
ij.launch(); | |
// Show the user interface. | |
ij.ui().showUI(); | |
// Write some stuff to the console. | |
System.out.println("It's the output stream!"); | |
System.err.println("It's the error stream!"); | |
// Launch the command. | |
ij.command().run(ConsoleManipulator.class, true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment