Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

Returning value from popup box

Thread view: 
Arun Hallan - 07 Jan 2004 22:31 GMT
Heres my problem:

Theres two boxes on the main screen. Theres two boxes in the dialog
screen. I want to open the dialog screen, type something into the
boxes then press update so it will update the main screen.

I've used showInputDialog, but i want more control over the layout of
the dialog screen and also i want two text boxes in it too.

Can any1 help?
Thanks
Andrew Thompson - 08 Jan 2004 05:56 GMT
..
| Theres two boxes on the main screen. Theres two boxes in the dialog
| screen. I want to open the dialog screen, type something into the
| boxes then press update so it will update the main screen.

Use a Dialog(s) or JDialog(s)..
http://www.physci.org/launcher.jsp#DialogInput

HTH

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Arun Hallan - 08 Jan 2004 17:39 GMT
> ..
> | Theres two boxes on the main screen. Theres two boxes in the
[quoted text clipped - 7 lines]
>
> HTH

2 problems:

1. I've used showInputDialog, but i want more control over the layout of
the dialog screen

2. and also i want two text boxes in it too.
Tor Iver Wilhelmsen - 08 Jan 2004 19:47 GMT
> 1. I've used showInputDialog, but i want more control over the layout of
> the dialog screen
>
> 2. and also i want two text boxes in it too.

Then write a subclass of Dialog or JDialog, add the components,
listeners etc.
Arun Hallan - 08 Jan 2004 20:10 GMT
I think this is what i need.
Can you briefly explain how to?
Shall i inherit the class JDialog and then what?
Its confusing...

If ive created the Dialog class, and i tell it to return the value from a
textField, how can i retrieve it in the parent class...

Im confused!

> > 1. I've used showInputDialog, but i want more control over the layout of
> > the dialog screen
[quoted text clipped - 3 lines]
> Then write a subclass of Dialog or JDialog, add the components,
> listeners etc.
Adam - 09 Jan 2004 07:29 GMT
> I think this is what i need.
> Can you briefly explain how to?
> Shall i inherit the class JDialog and then what?

Then you make it modal (with setModal(true)).
Then you put any GUI elements that you need
(two JTextFiields in your case) and OK, Cancel buttons.
Add a doModal() method which shall return
null if user cancels and a desired object (composed of
two Strings) otherwise. Add a private instance variable 'retval'
of the type that you will be returning from doModal().
In doModal you should call setVisible(true)
and afterwards - return retval;
To OK button add an action listener which will:
assign to retval current contents of the textfields
and setVisible(false);
To Cancel button add an action listener which will
assign null to retval and setVisible(false).

That's much all you need.

Adam
Andrew Thompson - 09 Jan 2004 00:44 GMT
| > ..
| > | Theres two boxes on the main screen. Theres two boxes in the
[quoted text clipped - 5 lines]
| > Use a Dialog(s) or JDialog(s)..
| > http://www.physci.org/launcher.jsp#DialogInput

| 2 problems:
|
| 1. I've used showInputDialog, but i want more control over the layout of
| the dialog screen

That's not a problem with Dialog
(or JDialog)

| 2. and also i want two text boxes in it too.

So pass an Object..

class DialogData
{
   public String fieldName, fieldValue;

   DialogData(String fieldName, String fieldValue)
   {
       this.fieldName = fieldName;
       this.fieldValue  = fieldValue;
   }
}

/* ..in the Frame, pass the DialogData object
to the Dialog constructor, or have a  Dialog
method that instantiates and returns a
DialogData object */

'Problem's solved..

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.