Re: "No" button within GenericDialog class feature update

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/No-button-within-GenericDialog-class-feature-update-tp5022458p5022459.html

Hi Philippe,

yes, I would also like to have more functionality for additional
buttons, and I am sometimes "misusing" the "No" button for such purposes.

In your sample code, after gd.showDialog() I think that the code will
never again be able to react to the dialog, even if the dialog remains
on the screen?

So I think we need some callback, using the DialogListener and/or
ActionListener interface.

So my dream would be a GenericDialog method
   Button[] addBottomButtons(String[] buttonLabels)
which adds one or more buttons at the position where usually the 'no'
button would appear.
Or, alternatively,
   Button addBottomButton(String buttonLabel)
which could be called multiple times (the buttons would go into a Vector
or ArrayList)

Then the user plugin could either use the references to the buttons and
register as an ActionListener for them, or it could register as
DialogListener and it would get its dialogItemChanged method called when
the user presses a button while the dialog window is still open.

Of course, the same could be done already now by adding a panel with the
buttons, and registering for each of them as ActionListener, but that is
more cumbersome, and in many cases one wants the button(s) at the bottom.

(unfortunately, I can't quickly do the coding now; too much unfinished
work on my desk)


Michael
________________________________________________________________
On 24.09.19 17:09, CARL Philippe (LBP) wrote:

> Dear all,
> Within the GenericDialog class it is now possible to add an additional button and even customize its name (see enableYesNoCancel(java.lang.String yesLabel, java.lang.String noLabel) method).
> Nevertheless, it would additionally be interesting to have this custom "No" button being able to launch a method without launching itself the GenericDialog dispose() method, for example for having an "Apply" button which would not close the dialog like I illustrated it within the small plugin that can be found here:
> http://punias.free.fr/ImageJ/test/My_Plugin.java
> that can be linked with the GenericDialog update try that can be found within:
> http://punias.free.fr/ImageJ/test/GenericDialog.java
> Nevertheless I don't know how I could define the method I would like to launch from "outside" the GenericDialog class.
> I thank you very much in advance for your lighting on this.
> My best regards
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 41 84
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html