× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



    Hi Larry,

    Paul's answer is correct, but it's not clear from your question if
anything else in your program runs in a GUI or if it's just a standard
program running only in the main thread.

    Either way, a modal dialog is the answer.  Modals have two primary
attributes:

1) Nothing else in your program can receive input until the modal dialog is
dismissed.

2) The invocation doesn't return until the modal is dismissed.

    There are some other things that can go on, but the two factors above
are primary.  The application to your program is the second one.  You can
find plenty of examples of modal dialogs in GUI apps, see The Java Tutorial
for example.  You can also invoke a modal in a program that has no other GUI
and cause the main thread to wait because the modal invocation doesn't
return until the dialog is dismissed.

    Below is a very basic program that demonstrates the main thread waiting.
Note that the console output doesn't print until you close each dialog.

------------------------------------------
import javax.swing.*;

public class xxx
{

  public static void main( String[] args )
  {
    JFrame jf = new JFrame();
    JDialog jd = new JDialog( jf, "MyTitle", true );

    JOptionPane.showMessageDialog( null, "Ima Message" );
    System.out.println( "JOptionPane completed" );

    jd.setSize( 300, 300 );
    jd.show();
    System.out.println( "Modal JDialog completed" );

    jd.dispose();
    jf.dispose();

    System.exit( 0 );
  } // end main

} // end class xxx
------------------------------------------

    BTW, you never need to call super() with no args; the compiler does it
for you internally.

    HTH,


                                                         Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO       -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?            http://www.jguru.com/faq/Java400


----- Original Message ----- 
From: "Clapham, Paul" <pclapham@xxxxxxxxxxxxx>
To: "Java Programming on and around the iSeries / AS400"
<java400-l@xxxxxxxxxxxx>
Sent: Thursday, March 17, 2005 11:04 AM
Subject: RE: Authenticator Question


> This is normal behaviour for Java GUI programs. The main program keeps on
going, as you say, while the GUI runs in a separate thread called the "event
thread". Normally you don't notice this because the main program starts the
GUI and then does nothing else, leaving the GUI the only active thread.
>
> If you called "Authenticator a = new MyAuthenticator()" in the event
thread (e.g. in response to a button click or some other GUI event), and if
your JDialog was a modal dialog, then you would have to key in your
information before "Authenticator.setDefault(a)" would be called.
>
> PC2
>
> -----Original Message-----
> From: java400-l-bounces+pclapham=core-mark.com@xxxxxxxxxxxx
[mailto:java400-l-bounces+pclapham=core-mark.com@xxxxxxxxxxxx] On Behalf Of
Larry
> Sent: March 17, 2005 05:56
> To: java400-l@xxxxxxxxxxxx
> Subject: Authenticator Question
>
>
> I wrote a small authenticator class.  It is designed to pop up a window,
allow the user to type in their information and return a
PasswordAuthentication object.  To do this when the authenticator is
created, in the constructor I pop up the window.
>
> public MyAuthenticator() {
> super();
> getJDialog();
> JDialog.show();
>
> In my button on the window I take the values and move them to strings
which get sent back in the protected PasswordAuthentication
getPasswordAuthentication() method which consists simply of return (new
PasswordAuthentication (uname,pass.toCharArray())).
>
> In my main program that uses the authenticator I do the following:
>
>                 ........
> Authenticator a = new MyAuthenticator();
> Authenticator.setDefault(a);
>                 ........
>
> When I run this code, the window pops up in the Authenticator class, but
the main program seems to keep chugging along - not waiting for my data
entry into the window.  The window itself works fine, but the main program
just seems to not want to wait for the data coming back from it.
>
> I know the authenticator class works fine other than the GUI.  If I
supress the GUI and just force in a user name and password, everything runs
fine.  When I put in the GUI, it does not.
>
> Any ideas where I may be going wrong?
>
> Larry
>
>


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.