JDialog and returning value

Discussion in 'Java' started by mdema@diesel, Jul 18, 2008.

  1. mdema@diesel

    mdema@diesel Guest

    Hi everybody
    I'd like a JDialog to return a value (a string, in this case) when is
    closed.
    Is this possible?
    My situation is like this:
    I have a main frame, then the Dialog is opened, some datas are put by
    the user in a text area and then the dialog is closed, but I need to
    access those datas.
    Thank you very much!
    mdema@diesel, Jul 18, 2008
    #1
    1. Advertising

  2. mdema@diesel

    Stefan Ram Guest

    "mdema@diesel" <> writes:
    >I'd like a JDialog to return a value (a string, in this case) when is
    >closed.
    >Is this possible?


    You can implement an extension of this class with a method:

    public java.lang.string close();

    But this would be misleading to others, since usually a close
    operation (as in java.io.Closeable) does not return a value.

    Another possibility:

    Make the object of your custom dialog class to be a component
    with an external model. Then, have the controller of the
    custom dialog component write the input read into the model.
    Then, even after the component has been closed, the data read
    will still be in the model.
    Stefan Ram, Jul 18, 2008
    #2
    1. Advertising

  3. mdema@diesel wrote:
    > Hi everybody
    > I'd like a JDialog to return a value (a string, in this case) when is
    > closed.
    > Is this possible?
    > My situation is like this:
    > I have a main frame, then the Dialog is opened, some datas are put by
    > the user in a text area and then the dialog is closed, but I need to
    > access those datas.
    > Thank you very much!


    See the docs; JOptionPane.showInputDialog() it does exactly what you want.

    If you need something more complicated than a single String then just
    get the data from the components in the dialog after it is closed.

    --

    Knute Johnson
    email s/nospam/knute2008/

    --
    Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    ------->>>>>>http://www.NewsDemon.com<<<<<<------
    Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
    Knute Johnson, Jul 18, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lukasz Indyk
    Replies:
    6
    Views:
    486
    Andrew Thompson
    Jan 23, 2004
  2. Mike Westerfield

    setFullScreenWindow and JDialog

    Mike Westerfield, Apr 4, 2004, in forum: Java
    Replies:
    0
    Views:
    1,444
    Mike Westerfield
    Apr 4, 2004
  3. javaseeker

    Applet calls to JDialog and JPanel

    javaseeker, Jun 14, 2004, in forum: Java
    Replies:
    2
    Views:
    4,229
    Andrew Thompson
    Jun 14, 2004
  4. mwmann
    Replies:
    4
    Views:
    12,779
    mwmann
    Aug 22, 2006
  5. Edsoncv

    newbie Threads and JDialog

    Edsoncv, Nov 15, 2007, in forum: Java
    Replies:
    1
    Views:
    283
    Andrew Thompson
    Nov 15, 2007
Loading...

Share This Page