How to increase the width of the main Fiji window at startup

I have enough plugins loaded that my Fiji main menu has switched to two lines. I know that I can set the x and y positions with ij.x=227 and ij.y=15 in IJ_prefs.txt. I tried ij.width=650 but that did not work. What am I missing?

I once suggested to auto-resize the toolbar to fit the actual menu size (if not in ImageJ 1.x, then in the imagej-legacy layer, since that’s also the one allowing to create new top-level menus):

… but as far as I know, nobody had time to pursue this issue (and I consider it less important than other issues).

The main conclusion was, for developers: “don’t add new top-level menus!”, and for users, in reply to the concern that the plugins menu is overcrowded already: “use the new command finder!” :slightly_smiling_face:

I did some more searching and found this from Curtis Reuden. My minor adaptation of his javascript code, shown below, worked for me.

importClass(Packages.ij.IJ)
importClass(Packages.java.awt.Dimension)
// for mac, the menubar is on top but I like the wider window to prevent
// overwriting the search panel with messages...
// IJ.getInstance().setSize(new Dimension(810, 90)) 
// for windows we need a larger height because the menu is in the window
IJ.getInstance().setSize(new Dimension(810, 125))

The downside is that the change is not persistent, The best I came up with is to put the script in the plugins folder and run it using the search box. I need to see if there is a way to force a script to run on startup. Back to searching…

1 Like

To make the change persistent, add

eval("js","IJ.getInstance().setSize(800,125)");

to the Edit>Options>Startup dialog.

1 Like

Thank you, Wayne.

I tried this as demonstrated below:
set_as_wayne_suggested

And it was not persistent. What works for now is using Plugins > Macros > Run to load and run the script.

Am I missing something? I am running an up-to-date Fiji installation and have tried this both on MacOS and Windows (64). The windows box is ImageJ 2.0.0-rc69/1.52n / Java 1.8.0_172 (64 bit).

Wayne, do you have any suggestions to see why the change is not persistent as we hoped?

1 Like

This appears to be a Fiji-related problem. It is persistent in ImageJ.

Another way to increase the width of the main ImageJ window is to set “GUI scale” in the Edit>Options>Appearance dialog to a value greater than 1.0. The following screenshot shows the ImageJ window on Linux with the standard settings (Menu font size=0, GUI scale=1.0) and beneath it the ImageJ window with Menu font size=10 and GUI scale=1.3. I found I had to sometimes set “Menu font size” separately from “GUI scale”.

1 Like

I have tried Wayne’s suggestions and there are enough differences between ImageJ and Fiji that Fiji will not autorun the javascript macro on startup. I will ask @ctrueden if he can offer a way to automatically run a javascript macro when Fiji starts. That is the last piece I need. I would like to thank all of those who have offered suggestions. I have learned a lot by working through this problem and am thanklful for the patience and assistance of all who have participated.

Yes, there are a couple of ways:

  1. Place a .js script within the plugins/Scripts/Plugins/AutoRun folder.
  2. Place a .ijm macro within the macros/AutoRun folder.

However, the issue is not the execution at startup, but rather the fact that with ImageJ2, startup macros and scripts run before the main window is packed and shown. So your changes to the window size get overridden by the display logic later.

You can test this by create a file macros/AutoRun/Resize_Main_Window.ijm with the contents:

print("BEGIN Resize_Main_Window macro");
eval("js","IJ.log(\"Resize_Main_Window BEGIN\");");
eval("js","IJ.getInstance().setSize(800,125)");
eval("js","IJ.log(\"Resize_Main_Window END\");");
print("END Resize_Main_Window macro");

And then launching Fiji. You’ll see that the print statements do happen… before the main ImageJ window appears.

Here is a working version of the Resize_Main_Window.ijm macro that reacts to the window’s appearance by changing the window size:

eval("js","IJ.getInstance().addWindowListener(new java.awt.event.WindowAdapter() { windowOpened: function(e) { IJ.getInstance().setSize(800, IJ.getInstance().getSize().height); }});");

Thank you so much, Curtis! I got this to work following your suggestion and uncovered what I think was a gremlin all along… The key is that the scripts seem to run in alphabetical order.

I now have 4 scripts in my AutoRun folder:

  • AutoRun_Scripts.ijm
  • bf-speed.ijm: It makes bioformats load faster
  • Register_Jay_Reader.ijm - from Stowers thst runs a wait(2000); to allow Bioformats to intialize and then runs run("register jay readers jru v1");
  • Resize_Main_Window.ijm

In this order the Resize_Main_Window.ijm does not appear to run; If I change the name to qResize_Main_Window.ijm` so that it runs just before Jay Unruh’s plug-in everything is fine. It did not occur to me that order mattered…