Login  Register

Re: GenericDialog programmatic "OK" ?

Posted by Wayne Rasband on Jul 17, 2009; 9:25pm
URL: http://imagej.273.s1.nabble.com/GenericDialog-programmatic-OK-tp3691723p3691724.html

The v1.43d daily build adds a getButtons() method to the GenericDialog
class. This is what it looks like:

     /** Returns references to the "OK" ("Yes"), "Cancel",
         and if present, "No" buttons as an array. */
     public Button[] getButtons() {
         Button[] buttons = new Button[3];
         buttons[0] = okay;
         buttons[1] = cancel;
         buttons[2] = no;
         return buttons;
     }

The daily build also allows you to drag images, text files (.txt,
.java, .js) and plugins (.jar, .class) from a browser window and drop
them on the ImageJ window. Images and text files are displayed and
plugins are installed.

-wayne

On Jul 17, 2009, at 14:31, Michael Schmid wrote:

>
> Hi Joachim,
>
> you could call gd.actionPerformed with a new ActionEvent that has the
> OK button as a source. The problem: there is no GenericDialog method
> that returns a reference to this button.
>
> It would be great to have GenericDialog function that returns the
> list of Buttons (this would be helpful also for other purposes, e.g.,
> enabling/disabling/changing a Button label).
> Otherwise, you have to step through the components of gd.getComponents
> () to find the panel with the buttons and then step through its
> getComponents() to find the OK button.
>
> Michael
> ________________________________________________________________
>
> On 17 Jul 2009, at 14:13, Joachim Wesner wrote:
>
> > Hi,
> >
> > just another question....
> >
> > I have a plugin that somehow streches the possibilities of
> > GenericDialog
> > but I am too lazy to rewrite the GUI using "standard java" in a
> plugin
> > frame.
> >
> > I have a DialogListener thar directly responds to some checkboxes
> > to, for
> > example, read a data file and fill in some of the dialog fields
> > based on
> > that.
> >
> > I would like to add the option that after reading these data, the
> > dialog is
> > automatically closed and processing starts immediately, i.e. I
> > somehow need
> > to
> > simulate clicking "OK" by the user from within the DialogListener .
> > What
> > would be the easiest way to acchieve this?
> >
> > Mit freundlichen Grüßen / Best regards
> >
> > Joachim Wesner
>