Login  Register

Re: Hypertext links in IJ.showMessage

Posted by Rasband, Wayne (NIH/NIMH) [E] on Jun 08, 2010; 7:35pm
URL: http://imagej.273.s1.nabble.com/Hypertext-links-in-IJ-showMessage-tp3687773p3687774.html

On Jun 8, 2010, at 9:44 AM, Michael Doube wrote:

> All,
>
> Is there a way to make a URL in an ImageJ error or message dialog
> 'hyper', i.e., so the user can just click on the text to go to a website?
>
> A quick google of the web and search of the IJ source was not fruitful.

You can add a "Help" button that opens a URL to GenericDialogs. With v1.44c and later, you can specify the font used to display the error message and the label used by the "Help" button. Here is an example:

   void error(String title, String message) {
      GenericDialog gd = new GenericDialog(title);
      Font font = new Font("SansSerif", Font.PLAIN, 16);
      gd.addMessage(message, font); // requires 1.44c
      gd.addHelp("http://rsb.info.nih.gov/ij/");
      gd.setHelpLabel("More Information"); // requires 1.44c
      gd.hideCancelButton();
      gd.showDialog();
   }

-wayne