Results 1 to 4 of 4
  1. #1
    sweetpea123 is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default JOptionPane with String

    Hi Guys,
    I figured it out thanks for the help:D
    Last edited by sweetpea123; 03-27-2010 at 10:35 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by sweetpea123 View Post
    Hi Guys,
    I am making a rental car program that is supposed to print out the customers information in one single box. The problem is that mine is showing up in mulitiple boxes. My teacher suggested that I make 2 strings to have the information show up in JOptionPane.showMessageDialog().
    This is what the API documentation has to say about the single 'message' parameter for your JOptionPane:

    A descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type:

    Object[]
    An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.

    Component
    The Component is displayed in the dialog.

    Icon
    The Icon is wrapped in a JLabel and displayed in the dialog.

    others
    The object is converted to a String by calling its toString method. The result is wrapped in a JLabel and displayed.
    So wrap all your information in another JComponent (or in an Object[]) and you're in business.

    kind regards,

    Jos

  4. #4
    sweetpea123 is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    I forgot to add the code tags sorry guys!! I will try your suggestion about wrapping text and then adding it to a JLabel. Any other suggestions would be helpful though :)
    Last edited by sweetpea123; 03-21-2010 at 06:46 PM.

Similar Threads

  1. JOptionPane
    By izzy in forum New To Java
    Replies: 1
    Last Post: 03-17-2010, 04:55 PM
  2. need help for JOptionPane....
    By keycoffee in forum New To Java
    Replies: 1
    Last Post: 02-09-2010, 08:59 AM
  3. JOptionPane String to int question
    By blackstormattack in forum New To Java
    Replies: 3
    Last Post: 03-08-2009, 12:14 AM
  4. JOptionPane
    By whosadork in forum New To Java
    Replies: 2
    Last Post: 10-23-2008, 02:17 AM
  5. String array for Choice, JOptionPane doesn't show
    By themburu in forum Java Applets
    Replies: 5
    Last Post: 05-29-2008, 01:10 PM

Posting Permissions

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