You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by we...@gmx.net on 2010/06/24 09:28:44 UTC

Example for input dialog

Hi!

I need an input dialog to get some info from the user.
I would prefere to have this dialog completely encapsulated and not
directly wired to my main application class.

Something like this would be nice.

MyDialog dlg = new MyDialog()
dlg.show;
dlg.getDataX();
dlg.getDataZ();

So the dialog itself needs the logic to handle userinputs.

Is there an example around that I could use?

Thx!

-- 
GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl

Re: Example for input dialog

Posted by Greg Brown <gk...@mac.com>.
Ah, I see. I hadn't looked closely enough at the original email so I didn't see the pseudocode.

Here's an example that uses BXML. It pushes the window logic into a MyWindow class that is also defined in BXML (though the current tutorials don't reflect this, it is generally best to keep the application class as free as possible of UI handling code).



On Jun 24, 2010, at 8:43 AM, Chris Bartlett wrote:

> On Thu, Jun 24, 2010 at 7:20 PM, Greg Brown <gk...@mac.com> wrote:
> I noticed that you pass the dialog's owner to the constructor. Any reason you don't just use the open() method?
> 
> 
> No deep thinking behind it, just a quickly hacked together demo.
> I was just trying to keep the code as close as possible to the original pseudo-code (hence the creation of a show() method), but by that token I should have passed the DialogCloseListener into the constructor too (or neither of them)
> 
> Chris
> 


Re: Example for input dialog

Posted by Chris Bartlett <cb...@googlemail.com>.
On Thu, Jun 24, 2010 at 7:20 PM, Greg Brown <gk...@mac.com> wrote:

> I noticed that you pass the dialog's owner to the constructor. Any reason
> you don't just use the open() method?
>
>
No deep thinking behind it, just a quickly hacked together demo.
I was just trying to keep the code as close as possible to the original
pseudo-code (hence the creation of a show() method), but by that token I
should have passed the DialogCloseListener into the constructor too (or
neither of them)

Chris

Re: Example for input dialog

Posted by Greg Brown <gk...@mac.com>.
Thanks for the example Chris. I'm working on converting it to BXML to demonstrate how the same thing can be done in markup.

I noticed that you pass the dialog's owner to the constructor. Any reason you don't just use the open() method?

@Override
public void buttonPressed(org.apache.pivot.wtk.Button button) {
    final MyDialog myDialog = new MyDialog("MyDialog");
    myDialog.open(window, myDialogCloseListener);
}


On Jun 24, 2010, at 7:02 AM, Chris Bartlett wrote:

> Have a look at this, and let me know if you have any problems.  (It was written against the current trunk)
> I'm no Pivot expert, so perhaps someone else can suggest cleaner/simpler/better alternatives.
> 
> The main app features a form to show the data collected from the MyDialog class, and a PushButton used to create and show a MyDialog instance.
> MyDialog itself extends Dialog.
> In order to keep the example as simple as possible, all Component creation is done in java and not with WTKX/BXML.
> 
> Regards,
> 
> Chris
> 
> On Thu, Jun 24, 2010 at 2:28 PM, <we...@gmx.net> wrote:
> Hi!
> 
> I need an input dialog to get some info from the user.
> I would prefere to have this dialog completely encapsulated and not
> directly wired to my main application class.
> 
> Something like this would be nice.
> 
> MyDialog dlg = new MyDialog()
> dlg.show;
> dlg.getDataX();
> dlg.getDataZ();
> 
> So the dialog itself needs the logic to handle userinputs.
> 
> Is there an example around that I could use?
> 
> Thx!
> 
> --
> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.
> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl
> 
> <MyDialog.zip>


Re: Example for input dialog

Posted by Chris Bartlett <cb...@googlemail.com>.
Have a look at this, and let me know if you have any problems.  (It was
written against the current trunk)
I'm no Pivot expert, so perhaps someone else can suggest
cleaner/simpler/better alternatives.

The main app features a form to show the data collected from the MyDialog
class, and a PushButton used to create and show a MyDialog instance.
MyDialog itself extends Dialog.
In order to keep the example as simple as possible, all Component creation
is done in java and not with WTKX/BXML.

Regards,

Chris

On Thu, Jun 24, 2010 at 2:28 PM, <we...@gmx.net> wrote:

> Hi!
>
> I need an input dialog to get some info from the user.
> I would prefere to have this dialog completely encapsulated and not
> directly wired to my main application class.
>
> Something like this would be nice.
>
> MyDialog dlg = new MyDialog()
> dlg.show;
> dlg.getDataX();
> dlg.getDataZ();
>
> So the dialog itself needs the logic to handle userinputs.
>
> Is there an example around that I could use?
>
> Thx!
>
> --
> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.
> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl
>