Display text label with @ script parameters

I was wondering if it possible to display a text label using the @script parameters for example to add a link to a wiki page of associated documentation.
I could use a @String but the idea would be to have something immutable. I dont think it is possible currently, possible future improvements ? Eventhough it is not a parameter per see…

Dear @LThomas,

You can use the visibility option for a @Parameter:

#@ String(visibility="MESSAGE", value="Something") somethingString
#@ String(value="Something else") somethingElseString

The first String will be an immutable label, while the second can be changed.



Thanks ! That could be worth adding to the wiki.
Is there some formatting to display hyperlink as well ?

It supports HTML as far as I know. You can try wrapping your text in <html></html> and add a link this way.

Well almost,
# @String(visibility="MESSAGE", value="<html><a href='http://forum.image.sc/'>This is my link</a></html>") Footer
indeed produce a html-formatted string but the link is not clickable :joy:

Sorry, should have thought about that!

@imagejan: Any idea where an issue for this should live? scijava-ui-swing?

1 Like

Yes, scijava-ui-swing is the correct repository for this.

The class responsible for displaying messages is SwingMessageWidget, which currently simply generates a JLabel with the text:

There’s some extra logic needed to make links work in JLabels, as discussed e.g. in these stackoverflow posts:

I opened an issue to track this:


Thanks for filing that issue, @imagejan!

Hi all, was there any update to this? It would be awesome to link to some documentation URL directly from the script the user is running…

1 Like

As you can see from the github issue, no…

I started a quick trial implementing JEditorPane as suggested in this old discussion on coderanch:

But it doesn’t work due to a NullPointerException thrown during dialog creation.

Feel free to test it and investigate if you find how to fix this. I’m not planning to invest any more time in it in the next weeks, so unless you or someone else picks it up, the issue might well sit there for another few months.

Regardless, …

I would strongly suggest to rely on the built-in behavior of the search bar that offers a help button for every command for free. Just create a wiki page for your command, and you’re all set.

Not messing with UI dialogs has the added benefit that your module/command/plugin/script will run in a number of headless environments (from within KNIME, from the command line, etc.) withtout any additional work.

1 Like

I just realized that when recorded using the macro recorder, the tag visibility="MESSAGE" result in having the string actually displayed in a pop-up OK/Cancel window.

Is there a way to prevent that ?
As long as the window is not closed the execution of the macro is interrupted…
Otherwise it works fine to have an uneditable documentation string in the GUI.
The other tags (“NORMAL”, “TRANSIENT”…) are unfortunately all for editable strings…

Does this work with any kind of macro ? How do you do that ?

Sorry I never got back to reply on this topic. Some of these things have been discussed in other topics as well, but just for completeness, to help others stumbling upon this:

This issue is being tracked here:

Suppose you have the following macro:

#@ String name

print ("Hello " + name + "!");

and you save this into Fiji.app/scripts/Plugins/Hello_World.ijm and restart Fiji, then:

  • the macro appears in the menu as Plugins > Hello World
  • you can search for e.g. “Hello” in the search bar, and the “Hello World” entry will show up,
    • pressing on Source will open the macro in the script editor
    • pressing on Help will open your browser at https://imagej.net/Hello_World

So all that remains for documenting your macro is creating a page at that URL (once the current website migration is done, via pull request on GitHub).