top of page

ImageJ-Fiji Quick Tip #3: your own text window

For this tip, goal is to see how it is possible to create your own text window in ImageJ/Fiji, instead of the default log window where you would see any printed info. This allows you to display some processing info in the main log and separate some text in a parallel window.

Application examples are: create a progress "bar", a special debug window, or some results data that you could optionally and easily save as a text file...

What's the code (skip the details)

  • Create your window (replace "MyTitle" but leave square brackets)

run("Text Window...", "name=[MyTitle] width=60 height=16");
  • Add text to it

print("[MyTitle]", "My first text line" +"\n");

print("[MyTitle]", "My next text line" +"\n");

Step by Step

  • Square brackets: They are not mandatory when you create the window, except if you are using space characters. They are mandatory when printing text in your window.

  • Carriage return: By default, it is inserted at the end of any use of the print function for the default log window. Though, it is not done with custom windows, so you will have to add it (except if you do not want to...).

  • Following the previous comment, you can use this window to concatenate text, and create a progress "bar" for instance...

run("Text Window...", "name=[Progress info] width=90 height=1");

for (i=0; i<100; i++) {
    print("[Progress info]", "*");

  • Wise choice of window's name: You can create as many windows as you want, but keep the titles clean :)

Extra tip to track progress

Instead of adding characters in your progress info window, you can think about replacing the content with updated text (using "\\Update:" prefix in the text input):

run("Text Window...", "name=[Progress info] width=90 height=1");

for (i=0; i<20; i++) {
    print("[Progress info]", "\\Update:Processing image: " + i+1);

Additional Thoughts

ImageJ and Fiji can become messy if you do not organize the layout in your screen. So creating an extra text window is somehow dangerous, except if you can automatically position it... :)

I usually use a function in the macro to handle this:

// move windows such as Threshold, B&C, etc.
function moveWin(name, xloc, yloc) {
	if (isOpen(name)) {
	     setLocation(xloc, yloc);

Just replace "name" with the title of your text window when you call this function, and use in-built functions to retrieve the size of your screen:

xloc = screenWidth - 100;
yloc = screenHeight - 50;
moveWin("MyTextWindow", xloc, yloc);

To keep up with what was said above, if you do not want to keep the new text window (temporary info), you might want to close it when macro is complete. Here is a reason for an extra function:

// close any window without returning any error
function closeWin(name) {
	if (isOpen(name)) {

Have fun!!!


bottom of page