Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: Dialog box not allowing user input?

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dialog box not allowing user input?

    Well im hoping someone can figure this out and i didnt see any other problems similar to this so hopefully its not a repeat...anyways here's my problem.
    When i use JOptionPane.showInputDialog("What's your name? "); everything shows up just fine but I can't input any text.

    my coding is fine - straight from the book - but is there anything that could be causing this problem?


  2. #2
    Member
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    69
    My Mood
    Bored
    Thanks
    11
    Thanked 7 Times in 6 Posts

    Default Re: Dialog box not allowing user input?

    With out the code, it appears to me you are using a "Message" dialog box. If your looking for input dialog as text check this demo out.

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Dialog box not allowing user input?

    ok so i just ran that demo and everything worked fine...except i still couldnt actually input an answer in the text box? it was responding cuz i could interact with the dialog box just not input any text.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Dialog box not allowing user input?

    As william said, it is difficult to comment on a problem specific for a piece of code without the code itself. We can guess - mine being does the text box have focus? But just guesses. Please post an SSCCE that demonstrates the problem.

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Dialog box not allowing user input?

    its not the coding thats the problem ...its super simple coding its something with my computer but anyways here's my code:

    import javax.swing.JOptionPane;
    public class NameDialog
    {
    public static void main (String [] args)
    {
    String name = JOptionPane.showInputDialog("What is your name?");
    String message = String.format ("Welcome, %s, to Java Programming!", name);
    JOptionPane.showMessageDialog (null, message);
    }
    }


    thanks so far by the way....hopefully we can get it figured out.

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Dialog box not allowing user input?

    Does a blinking cursor show up in the text box? If not, when you click in the text box does the cursor appear?

  7. #7
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Dialog box not allowing user input?

    no when i click in it nothing happens at all...i can still click "OK" or "cancel" but just not insert text - - no cursor ever

  8. #8
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Dialog box not allowing user input?

    Strange. What OS? JDK/JRE version?

  9. #9
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Dialog box not allowing user input?

    windows 7 64 bit
    java version "1.6.0_20"
    OpenJDK Runtime Environment (IcedTea6 1.9.10) (rhel-1.23.1.9.10.el5_7-x86_64)
    OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

  10. #10
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Dialog box not allowing user input?

    While I don't know much about all those version numbers, the output - if this is from just calling 'java -version' on the command line - doesn't look right (the 'rhel' looks like redhat linux eg. a linux version on windows?). My suggestion would be to reinstall the JDK and JRE from oracle, quadruple checking to make sure the correct OS is chose.

  11. #11
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Dialog box not allowing user input?

    Yea i did that but now how do i control the precedence of which my computer uses java - make it use the new version?

  12. #12
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Dialog box not allowing user input?

    Quote Originally Posted by michaelgilbert View Post
    Yea i did that but now how do i control the precedence of which my computer uses java - make it use the new version?
    Yes. Set the PATH to the newly installed version:
    PATH and CLASSPATH (The Java™ Tutorials > Essential Classes > The Platform Environment)

  13. #13
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Dialog box not allowing user input?

    ok i get the same dialog box but still cant insert text --- i just compiled it using
    ../src/jdk1.7.0_01/bin/javac and ran it with ../src/jdk1.7.0_01/bin/java
    instead of completely changing the classpath i just used the new java's bin folder to run it which essentially would do the same thing as changing the classpath right? anyways i still cant change the text grrrrrrr

  14. #14
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Dialog box not allowing user input?

    neirmind i got it all figured out....my friend suggested i use eclipse instead of putty and hey whaddya know everything works great .....3 weeks later and a gallon of tears

Similar Threads

  1. Valid user input
    By ChristopherLowe in forum Java Programming Tutorials
    Replies: 1
    Last Post: June 21st, 2011, 04:53 PM
  2. User Input File Name
    By PineAppleKing in forum Java Theory & Questions
    Replies: 12
    Last Post: June 3rd, 2011, 10:23 AM
  3. Allowing user to input variable.
    By That1guy in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 15th, 2010, 11:30 PM
  4. Simple Input Dialog Question
    By tabutcher in forum Java Theory & Questions
    Replies: 0
    Last Post: March 1st, 2010, 11:10 PM
  5. User Input Loop
    By cfmonster in forum Loops & Control Statements
    Replies: 7
    Last Post: August 24th, 2009, 01:52 PM