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 / June 2005

Tip: Looking for answers? Try searching our database.

Nontrivial dialog example

Thread view: 
Dennis E. Slice - 07 Jun 2005 17:45 GMT
Would someone provide or point me to an example of coding a simple, but
nontrivial, dialog?

For instance, I would like to provide a modal dialog that would allow the
user to, say, enter a string, an integer, and fiddle with some radio
buttons, and press OK or CANCEL to return.

I spend two frustrating days googling to no avail. I found lots of examples
of the use of the simple jOptionPanes and file and color choosers, but
nothing more custom. Those that purported to do so, even Sun's own
examples, used the deprecated "dialog.show()".

I am using eclipse and Java 1.5

TIA, dslice

 
Andrew Thompson - 07 Jun 2005 18:04 GMT
> Would someone provide or point me to an example of coding a simple, but
> nontrivial, dialog?
>
> For instance, I would like to provide a modal dialog that would allow the
> user to, say, enter a string, an integer, and fiddle with some radio
> buttons, and press OK or CANCEL to return.

It depends what you mean by 'non-trivial'..

This example obtains input from a simple text field in a dialog,
<http://www.physci.org/codes/display.jsp?fmt=ful&fl=/codes/input/DialogInput.java>
while this one shows a few buttons..
<http://www.physci.org/codes/display.jsp?fmt=ful&fl=/codes/AWT2/SampleDialog.java>

But what are you not clear on?  Building up a group of GUI
components?  Returning data to the parent?

I guess the reason you have found no specific examples is that
such things are so ..generic* that people tend not to think to
demonstrate them.

* You might demonstrate passing information using 2 command
line classes, while all layout stuff can be done in a (J)Panel
that might then be dumped into a (J)Frame, (J)Applet, (J)Window,
(J)Dialog or JOptionPane ..or another (J)Panel.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Dennis E. Slice - 07 Jun 2005 21:37 GMT
Andrew, Thanks. What I am not understanding is the sequence:

show dialog
* wait for user to close dialog (OK, CANCEL, CLOSE)
continue

It is the "wait" for return part I don't get my own dialogs. The standard
jOptionPanes do this automatically, it seems the dialog.show() can be used,
but is deprecated. I have no problem building dialogs or passing data
around. In fact, my dialog is already built and functioning, but I don't
know how to cleanly return to the program. Perhaps I am not understanding
the use of setVisible().

-dslice

>> Would someone provide or point me to an example of coding a simple, but
>> nontrivial, dialog?
[quoted text clipped - 6 lines]
>
> This example obtains input from a simple text field in a dialog,

<http://www.physci.org/codes/display.jsp?fmt=ful&fl=/codes/input/DialogInput.java>
> while this one shows a few buttons..

<http://www.physci.org/codes/display.jsp?fmt=ful&fl=/codes/AWT2/SampleDialog.java>

> But what are you not clear on?  Building up a group of GUI
> components?  Returning data to the parent?
[quoted text clipped - 7 lines]
> that might then be dumped into a (J)Frame, (J)Applet, (J)Window,
> (J)Dialog or JOptionPane ..or another (J)Panel.

 
Knute Johnson - 07 Jun 2005 22:08 GMT
> Andrew, Thanks. What I am not understanding is the sequence:
>
[quoted text clipped - 10 lines]
>
> -dslice

Modal dialogs 'wait' and modeless don't.  With a modal dialog, code
execution will stop at the Dialog.setVisible(true) statement until the
Dialog window closes.

From the API docs:
 "A dialog can be either modeless (the default) or modal. A modal
dialog is one which blocks input to all other toplevel windows in the
application, except for any windows created with the dialog as their owner."

Signature

Knute Johnson
email s/nospam/knute/

Fred L. Kleinschmidt - 07 Jun 2005 23:07 GMT
> ? Andrew, Thanks. What I am not understanding is the sequence:
> ?
[quoted text clipped - 14 lines]
> execution will stop at the Dialog.setVisible(true) statement until the
> Dialog window closes.

Not true. Perhaps you are thinking about JOptionPane's various
showXXXDialog() calls.


>  From the API docs:
>   "A dialog can be either modeless (the default) or modal. A modal
> dialog is one which blocks input to all other toplevel windows in the
> application, except for any windows created with the dialog as their owner."

this means that the user cannot interact with other dialogs. It does not
mean that the setVisible() call blocks.

> --
>
> Knute Johnson
> email s/nospam/knute/

Signature

Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94  (206)544-5225

Dennis E. Slice - 08 Jun 2005 14:10 GMT
BINGO! Thanks guys - Andrew/Knute. What I wasn't "getting" is that
setVisible(true) would display AND initiate the modal operation of the
dialog, and setVisible(false) would hide the dialog AND return execution to
the main program. All is cool, now. Again, thanks, -dslice

> Would someone provide or point me to an example of coding a simple, but
> nontrivial, dialog?
[quoted text clipped - 11 lines]
>
> TIA, dslice

_______________________________________________________________________________
> Posted Via Uncensored-News.Com - Accounts Starting At $6.95 -
> http://www.uncensored-news.com
>                <><><><><><><>   The Worlds Uncensored News Source  
>                <><><><><><><><>

 
Andrew Thompson - 08 Jun 2005 15:04 GMT
> BINGO! Thanks guys - Andrew/Knute.

No worries..   :-)

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



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.