Results 1 to 5 of 5
  1. #1
    saxophone is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default string prompt doesn't appear in showInputDialog

    I have the following code...

    newSpecialAbilityName = (String) JOptionPane.showInputDialog(parentGUI, "Enter name of Special Ability to add.", "xyz", JOptionPane.PLAIN_MESSAGE, null, null, "");

    The result is a dialog box that doesn't display the string, "Enter name of Special Ability to add."

    Also, only an OK button appears. There is no Cancel button. I adapted this from a Sun tutorial, and their example shows the Cancel button.

    What am I doing wrong?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by saxophone View Post
    What am I doing wrong?
    Strange, it works for me: the message and two buttons (OK and Cancel) are shown ...

    What Java version and make are you running?

    kind regards,

    Jos

  3. #3
    saxophone is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default

    java -version yields...

    java version "1.5.0_16"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
    Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)

    This is on a MacBook Pro using XCode 3.1.2 if that makes any difference.
    Last edited by saxophone; 04-01-2010 at 09:02 PM. Reason: additional info

  4. #4
    saxophone is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default

    I built a simple java program that just uses that statement, and the dialog comes up fine. However, when it is part of my larger program, it doesn't work. So somehow the larger program is doing something that is screwing up the dialog box. I'll dig around some more.

  5. #5
    saxophone is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default

    Here's some more information on my problem.

    Somewhere in the program, I have the following code...

    specialAbilitiesTable = new ScrollableTable(pc, new Dimension(810, 90));
    JScrollPane specialAbilitiesScrollPane = new JScrollPane(specialAbilitiesTable);
    specialAbilitiesScrollPane.setPreferredSize(new Dimension(810, 300));

    specialAbilitiesScrollPane.setBounds(0, y, 810, 300);
    add(specialAbilitiesScrollPane);

    specialAbilitiesTable is an instance of a class that extends JPanel.

    If I comment out the add(specialAbilitiesScrollPane) statement, the dialog works as intended.

Similar Threads

  1. Replies: 4
    Last Post: 03-25-2010, 04:47 PM
  2. Jcreator to DOS Prompt
    By arshesander in forum New To Java
    Replies: 5
    Last Post: 02-17-2010, 06:25 AM
  3. Problem in showInputDialog
    By mghaheri in forum New To Java
    Replies: 1
    Last Post: 03-05-2009, 11:29 PM
  4. JOptionPane.showInputDialog
    By mayhewj7 in forum New To Java
    Replies: 5
    Last Post: 02-25-2009, 06:04 AM
  5. Problem with JOptionPane.showInputDialog()
    By romina in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 05:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •