Results 1 to 3 of 3
  1. #1
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default [SOLVED] hello, need help about swing

    this is my code, it compiles and runs, but when i run this program there is a ''1'' in the showInput dialog, my instructor did not want the one to appear, so can someone tell me whats wrong here. thanx


    import javax.swing.*;

    public class MonogramSwing {

    public static void main(String[] args)
    {
    // declare any variables to be used
    String firstName, middleName, lastName;


    // give welcome and instructions to user
    JOptionPane.showMessageDialog(null,"\tWelcome to monogram");


    // prompt user for a message to be encoded
    firstName = JOptionPane.showInputDialog(null,"\tplease enter your firstname.",JOptionPane.INFORMATION_MESSAGE);


    middleName = JOptionPane.showInputDialog(null,"\tplease enter your middle initial.",JOptionPane.INFORMATION_MESSAGE);


    lastName=JOptionPane.showInputDialog(null,"\tpleas e enter your last name.",JOptionPane.INFORMATION_MESSAGE);


    // display the encoded message.
    JOptionPane.showMessageDialog(null,"\tYour monogram is "+ String.valueOf(firstName.charAt(0))+ String.valueOf(middleName.charAt(0)) + String.valueOf(lastName.charAt(0)),"THIS BOX WILL GIVE YOU YOUR MONOGRAM",JOptionPane.INFORMATION_MESSAGE);


    } // end of method main

    } // end of class MonogramSwing

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, you're using the "showInputDialog" with three arguments, which is
    Java Code:
    showInputDialog(Component parentComponent, Object message, Object initialSelectionValue)
    Isn't this the one you wanted, however?
    Java Code:
    showInputDialog(Component parentComponent, Object message, String title, int messageType)
    And wouldn't
    Java Code:
    JOptionPane.QUESTION_MESSAGE
    be preferable to
    Java Code:
    JOptionPane.INFORMATION_MESSAGE

  3. #3
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

Similar Threads

  1. swing.jar
    By krrishnak in forum AWT / Swing
    Replies: 2
    Last Post: 04-05-2009, 06:29 AM
  2. MVC and swing
    By jurka in forum AWT / Swing
    Replies: 1
    Last Post: 09-15-2008, 02:32 PM
  3. where is the swing jar?
    By katie in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 11:58 PM
  4. map javax.swing.text.Element to javax.swing.text.View
    By elizabeth in forum New To Java
    Replies: 1
    Last Post: 07-30-2007, 08:02 PM
  5. swing?? why use it
    By javaforme44a in forum AWT / Swing
    Replies: 3
    Last Post: 07-18-2007, 08:51 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
  •