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. Advertising

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. SuperChuck
    Replies:
    3
    Views:
    4,073
    Sandip Chitale
    Aug 7, 2003
  2. Arun
    Replies:
    4
    Views:
    10,750
  3. Eitan M

    showInputDialog

    Eitan M, Apr 4, 2006, in forum: Java
    Replies:
    6
    Views:
    10,619
    juanpenaz
    May 18, 2007
  4. mghaheri

    Problem in showInputDialog

    mghaheri, Mar 5, 2009, in forum: Java
    Replies:
    0
    Views:
    403
    mghaheri
    Mar 5, 2009
  5. Roger
    Replies:
    3
    Views:
    307
Loading...

Share This Page