Results 1 to 3 of 3

Thread: Subform Returns A Value

  1. #1

    Thread Starter
    Addicted Member MethadoneBoy's Avatar
    Join Date
    Oct 2001
    Location
    Preferably somewhere between Keira Knightley and Diane Kruger but I'm not fussy
    Posts
    180

    Subform Returns A Value

    Hi guys,

    Very noob-ish question here. How is it possible to programme a pop-up GUI (launched by clicking a button on a main GUI) to return a value? For instance, say you open this subform and it contains a TextField. You want whatever the user enters in the field to be visible to the main form once the subform has closed. Can this be done?

    Thanks.
    Last edited by MethadoneBoy; Apr 19th, 2007 at 05:41 AM.
    "'Oh, hello Mr. Crick! What do you think of Jeffrey Archer?' Clip-clip-clip! Oh, come on! Who are you kidding? You wait til I'm mayor, you'll see how tough I am! Christ almighty...."

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Subform Returs A Value

    Of course it can be done.

    The simplest way is by using the static methods of JOptionPane. They provide various standard dialog boxes.

    Failing that, there are various methods.
    1) The form opener could provide a place to store the value.
    2) The form opener could register a form listener on the form to detect it closing, then simply read out the relevant values. This is probably the best way as it is not too hard to implement, solves the issue of how to know when to fill in the data, and introduces no coupling from the child to the parent.
    3) The form could be passed a reference to the opener and set the values on closing directly. This is the worst option because it introduces child->parent coupling. To slightly alleviate this, you could just pass a specific interface that the parent implements for this purpose.

    JOptionPane is pretty flexible, though, and in general the preferred way of doing such things.
    Last edited by CornedBee; Apr 18th, 2007 at 03:33 PM.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Addicted Member MethadoneBoy's Avatar
    Join Date
    Oct 2001
    Location
    Preferably somewhere between Keira Knightley and Diane Kruger but I'm not fussy
    Posts
    180

    Re: Subform Returs A Value

    Quote Originally Posted by CornedBee
    Of course it can be done.

    The simplest way is by using the static methods of JOptionPane. They provide various standard dialog boxes.

    Failing that, there are various methods.
    1) The form opener could provide a place to store the value.
    2) The form opener could register a form listener on the form to detect it closing, then simply read out the relevant values. This is probably the best way as it is not too hard to implement, solves the issue of how to know when to fill in the data, and introduces no coupling from the child to the parent.
    3) The form could be passed a reference to the opener and set the values on closing directly. This is the worst option because it introduces child->parent coupling. To slightly alleviate this, you could just pass a specific interface that the parent implements for this purpose.

    JOptionPane is pretty flexible, though, and in general the preferred way of doing such things.
    Thanks for the response. I have actually used JOptionPanes a couple of times in my app but for one particular data-entry component, I'm sticking with using a subform for the time being due to the volume of data that this subform is designed to record.

    Also, one aspect of my app invloves using a FileChooser object to browse to the location of an XML file and reading in valued contained within. I'd like to implement this function on another subform and I'm not sure how a FileChooser object can be placed on a JOptionPane (can it?).

    The second option you mentioned sounds interesting. Are there any tips/tutorials you can point me to that would show me how to implement it?
    "'Oh, hello Mr. Crick! What do you think of Jeffrey Archer?' Clip-clip-clip! Oh, come on! Who are you kidding? You wait til I'm mayor, you'll see how tough I am! Christ almighty...."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width