focus with multiple JOptionPane.showInputDialog calls

Discussion in 'Java' started by Joseph M. DeAngelo, Nov 9, 2003.

  1. This must be simple but I can't get it. I have a simple standalone
    java program that tries to issue more than one input request from a
    Windows user. Here's the source:

    import javax.swing.*;

    public class focus
    {
    public static void main(String [] args)
    {
    String line;
    JOptionPane pane ;

    pane = new JOptionPane();
    line = pane.showInputDialog("Prompt1");
    line = pane.showInputDialog("Prompt2");

    System.exit(0);

    }
    }

    The first prompt brings up a dialog box that has keyboard input focus.
    If I type in some data and hit enter, the 2nd input dialog comes up
    but does not have the input focus. Is there any way to avoid having
    to tap the mouse button?
    I'm not a java programmer and am just trying to help someone else thru
    a programing course.

    Thanks....
     
    Joseph M. DeAngelo, Nov 9, 2003
    #1
    1. Advertisements

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. Arun
    Replies:
    4
    Views:
    11,191
  2. Eitan M

    showInputDialog

    Eitan M, Apr 4, 2006, in forum: Java
    Replies:
    6
    Views:
    10,812
    juanpenaz
    May 18, 2007
  3. Honne Gowda A
    Replies:
    2
    Views:
    1,106
    Karl Heinz Buchegger
    Oct 31, 2003
  4. andy6
    Replies:
    2
    Views:
    1,011
    andy6 via DotNetMonster.com
    Jun 9, 2006
  5. Richard Tobin
    Replies:
    24
    Views:
    1,136
  6. mghaheri

    Problem in showInputDialog

    mghaheri, Mar 5, 2009, in forum: Java
    Replies:
    0
    Views:
    480
    mghaheri
    Mar 5, 2009
  7. Bob
    Replies:
    5
    Views:
    472
  8. Roger
    Replies:
    3
    Views:
    620
Loading...